How to Output Timer Count lazarus / 31-LCL ---------------------------------------------------------------------- greertr · 2016-11-27 13:54 I used some code I found on one of these forum posts, but the little label doesnt read the countdown lit ought to...or at least I think it ought to... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit2; {$mode objfpc} interface uses  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,  StdCtrls, Clipbrd, Grids, ExtCtrls, EditBtn, ueled; type   { TForm2 }   TForm2 = class(TForm)    Button1: TButton;    Button2: TButton;    Button3: TButton;    Button4: TButton;    Button5: TButton;    Button7: TButton;    DateEdit1: TDateEdit;    GroupBox1: TGroupBox;    GroupBox2: TGroupBox;    GroupBox3: TGroupBox;    LCountodown: TLabel;    OpenDialog1: TOpenDialog;    SaveDialog1: TSaveDialog;    StringGrid1: TStringGrid;    StringGrid2: TStringGrid;    StringGrid3: TStringGrid;    Timer1: TTimer;    ToggleBox1: TToggleBox;    uELED1: TuELED;    LCountdown: TLabel;    procedure Button3Click(Sender: TObject);    procedure Button5Click(Sender: TObject);    procedure Button7Click(Sender: TObject);    procedure FormCreate(Sender: TObject);    procedure Button1Click(Sender: TObject);    procedure Button2Click(Sender: TObject);    procedure Button4Click(Sender: TObject);    procedure ToggleBox1Change(Sender: TObject);    procedure Timer1Timer(Sender: TObject);  private    { private declarations }    var    start: integer;  public    { public declarations }  end;  procedure DeleteRow(StringGrid: TStringGrid; ARow: integer); var  Form2: TForm2;implementation { TForm2 } procedure TForm2.Timer1Timer(Sender: TObject);begin  LCountdown.Caption := Format('%ds',[start]);  Dec(start);  if (start < 0) then begin    Timer1.Enabled := False;    LCountdown.Caption := 'Finished';  end;end; procedure TForm2.FormCreate(Sender: TObject);begin   //sets the SaveOptions at creation time of the form   //stringgrid1.SaveOptions := [soDesign];  stringgrid3.cells[0,1] := inttostr(stringgrid1.colcount);  stringgrid3.cells[1,1] := inttostr(stringgrid1.rowcount);  Timer1.Interval := 1000;  Timer1.Enabled := True;  LCountdown.Caption := '';  start := 15;  uELED1.Active:=false;end;procedure TForm2.Button5Click(Sender: TObject);begin  //Transfer flight data from the input grid to the log grid  StringGrid1.RowCount := StringGrid1.RowCount+1;  //insert row into stringgrid1  stringgrid1.rows[stringgrid1.rowcount-1] := stringgrid2.rows[1];  //transfer  stringgrid3.cells[0,1] := inttostr(stringgrid1.colcount);  stringgrid3.cells[1,1] := inttostr(stringgrid1.rowcount); end; procedure TForm2.Button3Click(Sender: TObject);begin    //delete any row where the selected cell is  DeleteRow(stringgrid1, stringgrid1.Row);  stringgrid3.cells[0,1] := inttostr(stringgrid1.colcount);  stringgrid3.cells[1,1] := inttostr(stringgrid1.rowcount);end; procedure TForm2.Button7Click(Sender: TObject);begin //helpend; procedure TForm2.Button4Click(Sender: TObject);begin  Form2.Visible := False;end; procedure TForm2.ToggleBox1Change(Sender: TObject);begin  //uELED1.Active:=false;  if ToggleBox1.Checked then    begin      ToggleBox1.Caption := 'Timer On';      uELED1.Active:=true;    end;   if not ToggleBox1.Checked then    begin      ToggleBox1.Caption := 'Timer Off';      uELED1.Active:=false;    end;end;procedure TForm2.Button1Click(Sender: TObject);   //load    {When using LoadFromFile the grid also uses the SaveOptions property in order to   know what kind of information needs to retrieve from the file, so is perfectly   possible to specify SaveOptions:=[soDesign,soContent] on saving and only   SaveOptions:=[soContent] on loading. }   //StringGrid1.RowCount:=StringGrid1.RowCount+1;  //insert row into stringgrid1  //SaveOptions:=[soDesign]; begin  //Form2.StringGrid3.LoadFromFile(OpenDialog1.FileName);   OpenDialog1.Filename := 'sg3rc.xml';  if OpenDialog1.Execute then     Form2.StringGrid3.LoadFromFile(OpenDialog1.FileName);  Form2.stringgrid1.ColCount := strtoint(stringgrid3.cells[0,1]);  Form2.Stringgrid1.rowcount := strtoint(stringgrid3.cells[1,1]);  OpenDialog1.Filename := 'pilot_log.xml';  if OpenDialog1.Execute then       Form2.StringGrid1.LoadFromFile(OpenDialog1.FileName);end; procedure TForm2.Button2Click(Sender: TObject);begin    //save  Form2.Stringgrid3.rowcount := stringgrid1.rowcount;  Form2.stringgrid3.ColCount := stringgrid1.colcount;  Form2.stringgrid1.SaveOptions := [soDesign, soContent];  SaveDialog1.Filename := 'pilot_log.xml';  if SaveDialog1.Execute then    Form2.StringGrid1.SaveToFile(SaveDialog1.FileName);  SaveDialog1.Filename := 'sg3rc.xml';  if SaveDialog1.Execute then   Form2.StringGrid3.SaveToFile(SaveDialog1.FileName);end; //Delete a row of a TStringGridprocedure DeleteRow(StringGrid: TStringGrid; ARow: integer);var  i, j: integer;begin  with StringGrid do  begin    if StringGrid.RowCount = 1 then   //dont del first row    exit;    for i := ARow to RowCount - 2 do      for j := 0 to ColCount - 1 do        Cells[j, i] := Cells[j, i + 1];    RowCount := RowCount - 1;  end;end; //make load button visible if the log file exists//  If FileExists(ParamStr(0)) Then//     Form2.Button1.Visible := true;  initialization  {$I unit2.lrs} end.  {//Delete a row of a TStringGridprocedure DeleteRow(StringGrid: TStringGrid; ARow: integer);var  i, j: integer;begin  with StringGrid do  begin    if StringGrid.RowCount = 1 then   //dont del first row    exit;    for i := ARow to RowCount - 2 do      for j := 0 to ColCount - 1 do        Cells[j, i] := Cells[j, i + 1];    RowCount := RowCount - 1;  end;end; You can use call easily: DeleteRow(sgCampos, sgCampos.Row);  }