-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdoubleclickmath.pas
More file actions
140 lines (123 loc) · 3.93 KB
/
doubleclickmath.pas
File metadata and controls
140 lines (123 loc) · 3.93 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
unit doubleclickmath;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
uSimpleGraph;
type
{ TmathForm }
TmathForm = class(TForm)
cancelButton: TButton;
CheckBoxSystemVar: TCheckBox;
ComboBoxVar1: TComboBox;
ComboBoxVar2: TComboBox;
ComboBoxVar3: TComboBox;
imageOperateur: TImage;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
OKbutton: TButton;
procedure cancelButtonClick(Sender: TObject);
procedure CheckBoxSystemVarChange(Sender: TObject);
procedure OKbuttonClick(Sender: TObject);
private
public
fsymbole : TObject;
end;
var
mathForm: TmathForm;
implementation
uses LadderSymbol,main;
{$R *.lfm}
{ TmathForm }
procedure TmathForm.cancelButtonClick(Sender: TObject);
begin
self.hide;
end;
procedure TmathForm.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;
procedure TmathForm.OKbuttonClick(Sender: TObject);
var
var1,var2,var3 : string;
i : integer;
begin
var1:=ComboBoxVar1.Text;
var2:=ComboBoxVar2.Text;
var3:=ComboBoxVar3.Text;
// check VAR1
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;
// check VAR2
if (form1.VARGrid.Cols[0].IndexOf(var2)=-1) and
(form1.SystemGrid.Cols[0].IndexOf(var2)=-1) and
(TryStrToInt(var2,i)) then
var2:=ComboBoxVar2.Text;
if (form1.VARGrid.Cols[0].IndexOf(var2)<>-1) or
(form1.SystemGrid.Cols[0].IndexOf(var2)<>-1) then
var2:=ComboBoxVar2.Text;
if (form1.VARGrid.Cols[0].IndexOf(var2)=-1) and
(form1.SystemGrid.Cols[0].IndexOf(var2)=-1) and
(not TryStrToInt(var2,i)) then
begin
form1.error(ComboBoxVar2.text+' is not a valid value');
exit;
end;
// check VAR3
if (form1.VARGrid.Cols[0].IndexOf(var3)=-1) then
begin
form1.error(ComboBoxVar3.text+' is not a valid value');
exit;
end;
TMath(fsymbole).var1:=var1;
TMath(fsymbole).var2:=var2;
TMath(fsymbole).var3:=var3;
TMath(fsymbole).textAllias.Text:=var3+'='+var1+TMath(fsymbole).getOperateur+var2;
TMath(fsymbole).equation:='('+var1+TMath(fsymbole).getOperateur+var2+')';
TSymbol(fsymbole).allias:=TMath(fsymbole).textAllias.text;
TEvsGraphObject(fsymbole).hint:=TMath(fsymbole).textAllias.text;
self.Hide;
end;
end.