1 | unit UFormAssembler;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, UAssembler;
|
---|
9 |
|
---|
10 | type
|
---|
11 |
|
---|
12 | { TFormAssembler }
|
---|
13 |
|
---|
14 | TFormAssembler = class(TForm)
|
---|
15 | ButtonCompile: TButton;
|
---|
16 | ButtonLoadFromFile: TButton;
|
---|
17 | ButtonSaveToFile: TButton;
|
---|
18 | MemoMessages: TMemo;
|
---|
19 | MemoSource: TMemo;
|
---|
20 | OpenDialog1: TOpenDialog;
|
---|
21 | SaveDialog1: TSaveDialog;
|
---|
22 | procedure ButtonCompileClick(Sender: TObject);
|
---|
23 | procedure ButtonLoadFromFileClick(Sender: TObject);
|
---|
24 | procedure ButtonSaveToFileClick(Sender: TObject);
|
---|
25 | procedure FormCreate(Sender: TObject);
|
---|
26 | procedure FormDestroy(Sender: TObject);
|
---|
27 | private
|
---|
28 | procedure DoCompileMessage(Text: string);
|
---|
29 | public
|
---|
30 | Assembler: TAssembler;
|
---|
31 | end;
|
---|
32 |
|
---|
33 | var
|
---|
34 | FormAssembler: TFormAssembler;
|
---|
35 |
|
---|
36 | implementation
|
---|
37 |
|
---|
38 | {$R *.lfm}
|
---|
39 |
|
---|
40 | { TFormAssembler }
|
---|
41 |
|
---|
42 | procedure TFormAssembler.ButtonLoadFromFileClick(Sender: TObject);
|
---|
43 | begin
|
---|
44 | if OpenDialog1.Execute then
|
---|
45 | MemoSource.Lines.LoadFromFile(OpenDialog1.FileName);
|
---|
46 | end;
|
---|
47 |
|
---|
48 | procedure TFormAssembler.ButtonCompileClick(Sender: TObject);
|
---|
49 | begin
|
---|
50 | Assembler.Source.Assign(MemoSource.Lines);
|
---|
51 | Assembler.Compile;
|
---|
52 | end;
|
---|
53 |
|
---|
54 | procedure TFormAssembler.ButtonSaveToFileClick(Sender: TObject);
|
---|
55 | begin
|
---|
56 | if SaveDialog1.Execute then
|
---|
57 | MemoSource.Lines.SaveToFile(SaveDialog1.FileName);
|
---|
58 | end;
|
---|
59 |
|
---|
60 | procedure TFormAssembler.FormCreate(Sender: TObject);
|
---|
61 | begin
|
---|
62 | Assembler := TAssembler.Create;
|
---|
63 | Assembler.OnError := DoCompileMessage;
|
---|
64 | end;
|
---|
65 |
|
---|
66 | procedure TFormAssembler.FormDestroy(Sender: TObject);
|
---|
67 | begin
|
---|
68 | FreeAndNil(Assembler);
|
---|
69 | end;
|
---|
70 |
|
---|
71 | procedure TFormAssembler.DoCompileMessage(Text: string);
|
---|
72 | begin
|
---|
73 | MemoMessages.Lines.Add(Text);
|
---|
74 | end;
|
---|
75 |
|
---|
76 | end.
|
---|
77 |
|
---|