-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdoubleclickflash.pas
More file actions
116 lines (96 loc) · 2.97 KB
/
doubleclickflash.pas
File metadata and controls
116 lines (96 loc) · 2.97 KB
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
unit doubleclickflash;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
VariableUnit;
type
{ TflashForm }
TflashForm = class(TForm)
cancelButton: TButton;
EditPresetValueON: TEdit;
EditPresetValueOFF: TEdit;
EditTimerName: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
OKbutton: TButton;
procedure cancelButtonClick(Sender: TObject);
procedure EditPresetValueOFFKeyPress(Sender: TObject; var Key: char);
procedure EditPresetValueONKeyPress(Sender: TObject; var Key: char);
procedure EditTimerNameKeyPress(Sender: TObject; var Key: char);
procedure OKbuttonClick(Sender: TObject);
private
public
fsymbole : TObject;
end;
var
flashForm: TflashForm;
implementation
{$R *.lfm}
uses LadderSymbol,main;
{ TflashForm }
procedure TflashForm.cancelButtonClick(Sender: TObject);
begin
hide;
end;
procedure TflashForm.EditPresetValueOFFKeyPress(Sender: TObject; var Key: char);
begin
if ord(key)=13 then OKbuttonClick(self);
end;
procedure TflashForm.EditPresetValueONKeyPress(Sender: TObject; var Key: char);
begin
if ord(key)=13 then OKbuttonClick(self);
end;
procedure TflashForm.EditTimerNameKeyPress(Sender: TObject; var Key: char);
begin
if ord(key)=13 then OKbuttonClick(self);
end;
procedure TflashForm.OKbuttonClick(Sender: TObject);
var
timerName,presetValueON : string;
presetValueOff : string;
i : integer;
begin
timerName := EditTimerName.Text;
presetValueON := EditPresetValueON.Text;
presetValueOFF := EditPresetValueOFF.Text;
// check timerName
if (form1.VARGrid.Cols[0].IndexOf(timerName)=-1) and
(form1.SystemGrid.Cols[0].IndexOf(timerName)=-1) and
(form1.IOplcGrid.Cols[0].IndexOf(timerName)=-1) and
(form1.TimerGrid.Cols[0].IndexOf(timerName)=-1)
then begin
end
else begin
ShowMessage('The name '+EditTimerName.text+' is already used');
exit;
end;
// check preset value
if (TryStrToInt(presetValueON,i)) and
(TryStrToInt(presetValueOFF,i)) then
begin
TFlash(fsymbole).presetON:=StrToInt(presetValueON);
TFlash(fsymbole).presetOFF:=StrToInt(presetValueOFF);
TFLASH(fsymbole).textAllias.text:=timerName;
TSymbol(fsymbole).hint:= TTon(fsymbole).textAllias.text+' '+
'ON='+presetValueON+' OFF='+presetValueOFF;
TSymbol(fsymbole).allias:=timerName;
timerList.Add(TTimerVar.create(timerName,presetValueON,presetValueON,presetValueOff,'TFlash'));
with form1 do
begin
TimerGrid.RowCount:=TimerGrid.RowCount+1;
TimerGrid.Cells[0,TimerGrid.RowCount-2]:=EditTimerName.Text;
TimerGrid.Cells[1,TimerGrid.RowCount-2]:='blink';
end;
end
else
begin
ShowMessage(presetValueON+' or '+presetValueOFF+' are not valid value');
exit;
end;
hide;
end;
end.