-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdoubleclickstore.pas
More file actions
115 lines (98 loc) · 3.01 KB
/
doubleclickstore.pas
File metadata and controls
115 lines (98 loc) · 3.01 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
unit doubleclickstore;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
uSimpleGraph;
type
{ TstoreForm }
TstoreForm = class(TForm)
cancelButton: TButton;
CheckBoxSystemVar: TCheckBox;
ComboBoxVar1: TComboBox;
ComboBoxVar2: TComboBox;
Label1: TLabel;
Label3: TLabel;
OKbutton: TButton;
Shape1: TShape;
Shape2: TShape;
procedure cancelButtonClick(Sender: TObject);
procedure CheckBoxSystemVarChange(Sender: TObject);
procedure OKbuttonClick(Sender: TObject);
private
public
fsymbole : TObject;
end;
var
storeForm: TstoreForm;
implementation
{$R *.lfm}
uses LadderSymbol,main;
{ TstoreForm }
procedure TstoreForm.OKbuttonClick(Sender: TObject);
var
var1,var2 : string;
i : integer;
begin
var1:=ComboBoxVar1.Text;
if (form1.VARGrid.Cols[0].IndexOf(var1)=-1) and
(form1.SystemGrid.Cols[0].IndexOf(var1)=-1) and
(TryStrToInt(var1,i)) then
var1:=ComboBoxVar1.Text;
if (form1.VARGrid.Cols[0].IndexOf(var1)<>-1) or
(form1.SystemGrid.Cols[0].IndexOf(var1)<>-1) then
var1:=ComboBoxVar1.Text;
if (form1.VARGrid.Cols[0].IndexOf(var1)=-1) and
(form1.SystemGrid.Cols[0].IndexOf(var1)=-1) and
(not TryStrToInt(var1,i)) then
begin
form1.error(ComboBoxVar1.text+' is not a valid value');
exit;
end;
var2:=ComboBoxVar2.Items[ComboBoxVar2.ItemIndex];
TStore(fsymbole).var1:=var1;
TStore(fsymbole).var2:=var2;
TStore(fsymbole).textAllias.Text:=var2+'='+var1;
TSymbol(fsymbole).equation:=var2+':='+var1;
TSymbol(fsymbole).allias:=TStore(fsymbole).textAllias.text;
TEvsGraphObject(fsymbole).hint:=TStore(fsymbole).textAllias.text;
self.Hide;
end;
procedure TstoreForm.cancelButtonClick(Sender: TObject);
begin
self.Hide;
end;
procedure TstoreForm.CheckBoxSystemVarChange(Sender: TObject);
var
i : integer;
selectedVar : integer;
begin
ComboBoxVar1.Clear;
ComboBoxVar2.Clear;
for i:=0 to varList.Count-1 do
if varList.Items[i].typeVar<>'BIT' then
begin
ComboBoxVar1.Items.Add(varList.Items[i].nameVar);
ComboBoxVar2.Items.Add(varList.Items[i].nameVar);
end;
if CheckBoxSystemVar.checked then
begin
for i:=1 to form1.SystemGrid.RowCount-1 do
if (form1.SystemGrid.Cells[1,i]<>'BIT') and
(form1.SystemGrid.Cells[0,i]<>'') then
begin
ComboBoxVar1.Items.Add(form1.SystemGrid.Cells[0,i]);
ComboBoxVar2.Items.Add(form1.SystemGrid.Cells[0,i]);
end;
end;
ComboBoxVar1.Sorted:=true;
ComboBoxVar2.Sorted:=true;
// select Var
selectedVar:=ComboBoxVar1.Items.IndexOf(Tcompare(fsymbole).Var1);
if selectedVar=-1 then ComboBoxVar1.ItemIndex:=0
else ComboBoxVar1.ItemIndex:=selectedVar;
selectedVar:=ComboBoxVar2.Items.IndexOf(Tcompare(fsymbole).Var2);
if selectedVar=-1 then ComboBoxVar2.ItemIndex:=0
else ComboBoxVar2.ItemIndex:=selectedVar;
end;
end.