forked from graemeg/epiktimer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
newsw.pas
134 lines (108 loc) · 2.58 KB
/
newsw.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
unit newsw;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
Grids, Buttons,EpikTimer;
type
TForm2 = class(TForm)
Button1: TBUTTON;
Button2: TBUTTON;
Button3: TBUTTON;
Button4: TBUTTON;
Button5: TBUTTON;
Button6: TBUTTON;
Button7: TBUTTON;
Button8: TBUTTON;
Edit1: TEDIT;
Edit2: TEDIT;
Edit3: TEDIT;
Edit4: TEDIT;
Edit5: TEDIT;
Edit6: TEDIT;
Groupbox1: TGROUPBOX;
Groupbox2: TGROUPBOX;
procedure Button1CLICK(Sender: TObject);
procedure Button2CLICK(Sender: TObject);
procedure Button3CLICK(Sender: TObject);
procedure Button4CLICK(Sender: TObject);
procedure Button5CLICK(Sender: TObject);
procedure Button6CLICK(Sender: TObject);
procedure Button7CLICK(Sender: TObject);
procedure Button8CLICK(Sender: TObject);
procedure Form2CREATE(Sender: TObject);
procedure Form2DESTROY(Sender: TObject);
private
ET:TEpikTimer;
LocalTimer:TimerData;
Procedure UpdateDisplay(Msg:String);
Procedure UpdateDisplayLocal(Msg:String);
public
{ public declarations }
end;
Var
Form2:Tform2;
implementation
{$R *.lfm}
{ TForm2 }
procedure TForm2.UpdateDisplay(Msg:String);
begin
edit1.text:=ET.ElapsedStr;
Edit2.text:=ET.elapsedDHMS;
edit4.text:=Msg+': '+ET.WallClockTime;
end;
procedure TForm2.Button2CLICK(Sender: TObject);
begin
ET.Start;
UpdateDisplay('Start')
end;
procedure TForm2.Button3CLICK(Sender: TObject);
begin
ET.Stop;
UpdateDisplay('Stop')
end;
procedure TForm2.Button4CLICK(Sender: TObject);
begin
ET.Clear;
UpdateDisplay('Clear')
end;
procedure TForm2.Button1CLICK(Sender: TObject);
begin
UpdateDisplay('Elapsed')
end;
(* This group uses a locally created timer *)
procedure TForm2.UpdateDisplayLocal(Msg:String);
begin
edit3.text:=ET.ElapsedStr(LocalTimer);
Edit5.text:=ET.elapsedDHMS(LocalTimer);
edit6.text:=Msg+': '+ET.WallClockTime;
end;
procedure TForm2.Button6CLICK(Sender: TObject);
begin
ET.Start(LocalTimer);
UpdateDisplayLocal('Start')
end;
procedure TForm2.Button7CLICK(Sender: TObject);
begin
ET.Stop(LocalTimer);
UpdateDisplayLocal('Stop')
end;
procedure TForm2.Button8CLICK(Sender: TObject);
begin
ET.Clear(LocalTimer);
UpdateDisplayLocal('Clear')
end;
procedure TForm2.Button5CLICK(Sender: TObject);
begin
UpdateDisplayLocal('Elapsed:')
end;
procedure TForm2.Form2CREATE(Sender: TObject);
begin
ET:=TEpikTimer.create(nil);
ET.Clear(LocalTimer) // you have to do this if you create a local timer
end;
procedure TForm2.Form2DESTROY(Sender: TObject);
begin
ET.Free
end;
end.