unit Unit1;
  (* zum Programm  P_1.LPR *) 

{$MODE OBJFPC}               // Object-Pascal-Modus 
{$H+}                        // Benutze ANSI-Strings 

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, 
  StdCtrls, 
  ExtCtrls;    // Für Anzeige1 erforderlich, in 'Additional' 

type
  
  (* TForm1 *)
  tForm1 = class(tForm)
    Button1  : tButton;
    Button2  : tButton;
    Edit1    : tEdit;
    progname : tLabel;
    procedure Create_(sender : tObject);
    procedure Button1Click(sender : tObject);
  private  (* Private Declarations *)
    procedure Button2Click(sender : tObject); 
    procedure Anzeige1  (sender : tObject)  ;
  public   (* Public Declarations *)
  end; (* of class tForm1 *)

var
  Form1  : tForm1; 
  buton1 : boolean;
  buton2 : boolean; 
  zaehl  : word; 
  

implementation

{$R *.lfm}         // Einbindung der *.lfm-Ressource(n) 
 
 procedure tForm1.Create_  (sender : tObject)  ; 
   begin 
   Application.Title     := 'P_1';      // Programm-Titelzeile setzen 
   Form1.Caption         := 'P_1';      // Titelzeile des Fensters/Formulars setzen 
   // Form1.Icon         := 'xxx.ico';  // Programm-Icon setzen 
   Form1.Button1.Caption := 'Start'; 
   Form1.Button2.Caption := 'Stop'; 
   Form1.Edit1.Text      := '';         // Angezeigte "Anzeige1" löschen 
   zaehl                 := 0;
   Edit1.Text            := IntToStr(zaehl);
   buton1                := false;
   buton2                := false;
   Anzeige1(sender);
   end; (* of procedure tForm1.Create_ *) 

   
 procedure tForm1.Button1Click(sender : tObject);
   begin
   // Showmessage ('Button 1 geklickt');
   buton1 := true; 
   end; (* of procedure tForm1.Button1Click *) 

 
 procedure tForm1.Button2Click  (sender : TObject)  ; 
   begin
   (* if buton2 = false then 
     close;             // Schließe das Formular == ganze Anwendung 
   *)
   // Form1.Button2.OnClick = true;
   buton2 := true; 
   buton1 := false;
   if buton2 = false then 
     close;             // Schließe das Formular == ganze Anwendung 
   end; (* of procedure tForm1.Button2Click *) 

   
 procedure tForm1.Anzeige1 (sender : tObject) ;
   begin
   if buton1 = true then 
     begin
     Form1.Button1.Caption := 'Pause';    
     repeat
       inc(zaehl);
       sleep(1000);     // 1 Sekunde warten 
       Form1.Edit1.Text := IntToStr(zaehl);
     until {Form1.} buton2 = true;
     buton2 := false;
     end; (* of if buton1 = true *) 
   end; (* of procedure tForm1.Anzeige1 *) 


end. (* of unit unit1 *) 
