-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathu_assifparser_testform.pas
80 lines (65 loc) · 1.39 KB
/
u_assifparser_testform.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
unit u_assifparser_testform;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ComCtrls,
u_assifparser_class;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
ListBox1: TListBox;
TreeView1: TTreeView;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
Parser:TAssiFormulaParser;
begin
Parser:=TAssiFormulaParser.Create;
TreeView1.Items.Clear;
if Parser.Execute(Edit1.Text) then
begin
Parser.UploadToTree(TreeView1);
ShowMessage(Parser.GetResultAsText);
end
else begin
ShowMessage('Error');
end;
Parser.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Parser:TAssiFormulaParser;
begin
Parser:=TAssiFormulaParser.Create;
TreeView1.Items.Clear;
if Parser.Parse(Edit1.Text) then
begin
Parser.UploadToTree(TreeView1);
end
else begin
ShowMessage('Error');
end;
Parser.Free;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
if ListBox1.ItemIndex<>-1 then
Edit1.Text:=ListBox1.Items.Strings[ListBox1.ItemIndex];
end;
end.