Changeset 140 for branches/easy compiler/UFormMain.pas
- Timestamp:
- Jan 16, 2018, 10:38:33 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/easy compiler/UFormMain.pas
r139 r140 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 UTargetCode, USourceCode ;9 UTargetCode, USourceCode, USourceExecutor, USourceGenerator; 10 10 11 11 type … … 14 14 15 15 TForm1 = class(TForm) 16 ButtonSend: TButton; 16 17 ButtonBuild: TButton; 18 Edit1: TEdit; 19 Label1: TLabel; 20 Label2: TLabel; 21 Label3: TLabel; 22 Label4: TLabel; 17 23 MemoOutput: TMemo; 18 24 MemoSource: TMemo; 25 MemoGenerator: TMemo; 19 26 procedure ButtonBuildClick(Sender: TObject); 27 procedure ButtonSendClick(Sender: TObject); 28 procedure FormCreate(Sender: TObject); 29 procedure FormDestroy(Sender: TObject); 20 30 procedure FormShow(Sender: TObject); 21 31 private 22 32 InputBuffer: TStringList; 33 procedure ExecutorOutput(Text: string); 34 function ExecutorInput: string; 23 35 public 24 procedure ExecutorOutput(Text: string);25 36 end; 26 37 … … 47 58 Add('PrintLn Text1'); 48 59 Add('PrintLn Text2'); 60 Add('InputLn Text3'); 61 Add('PrintLn Text3'); 49 62 end; 50 63 end; … … 64 77 Executor := TSourceExecutor.Create; 65 78 Executor.OnOutput := ExecutorOutput; 79 Executor.OnInput := ExecutorInput; 66 80 Generator := TSourceGenerator.Create; 67 81 68 82 Compiler.Compile(MemoSource.Text, SourceCode); 83 MemoGenerator.Text := Generator.Generate(SourceCode); 69 84 Executor.Execute(SourceCode); 70 Generator.Generate(SourceCode);71 85 72 86 Generator.Free; … … 77 91 end; 78 92 93 procedure TForm1.ButtonSendClick(Sender: TObject); 94 begin 95 InputBuffer.Add(Edit1.Text); 96 Edit1.Text := ''; 97 end; 98 99 procedure TForm1.FormCreate(Sender: TObject); 100 begin 101 InputBuffer := TStringList.Create; 102 end; 103 104 procedure TForm1.FormDestroy(Sender: TObject); 105 begin 106 InputBuffer.Free; 107 end; 108 79 109 procedure TForm1.ExecutorOutput(Text: string); 80 110 begin … … 82 112 end; 83 113 114 function TForm1.ExecutorInput: string; 115 begin 116 while InputBuffer.Count = 0 do begin 117 Sleep(50); 118 Application.ProcessMessages; 119 end; 120 Result := InputBuffer[0]; 121 InputBuffer.Delete(0); 122 end; 123 84 124 end. 85 125
Note:
See TracChangeset
for help on using the changeset viewer.