Ah. that make sense.
Thanks.
Too much regarding the other suggestion ?

No problemo. New form, 5 labels one button, code looking like this (will hopefully get you going). I cheated though by combining the two mentioned solutions into one.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
Var
i : Integer;
LabelArray : Array[1..5] of TLabel;
begin
// Temp disable button
(Sender as TButton).Enabled := false;
// Fill array with labels
For i := Low(labelArray) to High(labelArray) do
begin
LabelArray[i] := FindComponent('Label' + IntToStr(i)) as TLabel;
end;
For i := 1 to 5 do
begin
// Do some other stuff
// Change colour based on result from other stuff done above
// As for an example: use odd/even
if Odd(i)
then LabelArray[i].Font.Color:= clGreen
else LabelArray[i].Font.Color:= clRed;
// Make sure GUI gets updated between changes
Application.ProcessMessages;
// Perform some delay in order to humanly be able to follow GUI changes
Sleep(3000);
end;
// Restore default colour
For i := 1 to 5
do LabelArray[i].Font.Color:= clDefault;
// Enable button
(Sender as TButton).Enabled := True;
end;
end.
Is there a possibility to put more condition into a "If" statement?
Like: If i = 4 or 7 or 12 then
instead of
if i = 4 then
if i = 7 then
if i = 12 then
Again several solutions available, depending on the exact circumstances.
If (
(i = 4) or
(i =7) or
(i = 12)
)
then
Or
Case i of
1,2,3,4: begin {do something when i = 1,2,3 or 4} end;
5 : begin {do something when i = 5} end;
else begin {do something if i didn't match any of the above values } end;
end;