Changeset 141 for branches/easy compiler/UFormMain.pas
- Timestamp:
- Jan 16, 2018, 2:44:19 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/easy compiler/UFormMain.pas
r140 r141 26 26 procedure ButtonBuildClick(Sender: TObject); 27 27 procedure ButtonSendClick(Sender: TObject); 28 procedure Edit1KeyPress(Sender: TObject; var Key: char); 28 29 procedure FormCreate(Sender: TObject); 29 30 procedure FormDestroy(Sender: TObject); … … 51 52 begin 52 53 with MemoSource.Lines do begin 54 Add('PrintLn ''Super Calculator'''); 55 Add('var Value1 Integer'); 56 Add('var Value2 Integer'); 57 Add('var Result Integer'); 58 Add('Print ''Enter value 1: '''); 59 Add('Assign Value1 0'); 60 Add('InputLn Value1'); 61 Add('Print ''Enter value 2: '''); 62 Add('Assign Value2 0'); 63 Add('InputLn Value2'); 64 65 Add('Assign Result Value1'); 66 Add('Increment Result Value2'); 67 Add('Print ''Sum of two values is: '''); 68 Add('PrintLn Result'); 69 end; 70 { with MemoSource.Lines do begin 53 71 Add('PrintLn ''Hello World!'''); 54 72 Add('print ''Hello'' PRINT '' World!'''); 55 73 Add('PrintLn ''Live your life.'''); 74 Add('var Text1 String'); 56 75 Add('Assign Text1 ''Live your life.'''); 76 Add('var Text2 String'); 57 77 Add('Assign Text2 ''Live your life.'''); 58 78 Add('PrintLn Text1'); 59 79 Add('PrintLn Text2'); 80 81 Add('var Value1 Integer'); 82 Add('Assign Value1 123'); 83 Add('Increment Value1 2'); 84 Add('PrintLn Value1'); 85 86 Add('var Text3 String'); 87 Add('Assign Text3 '''''); 88 Add('Print ''Enter your name:'''); 60 89 Add('InputLn Text3'); 61 90 Add('PrintLn Text3'); 62 91 end; 92 93 with MemoSource.Lines do begin 94 Add('Assign AnimalName[0] ''an elephant'''); 95 Add('Assign AnimalProperty[0] ''It is big and slow'''); 96 Add('Assign AnimalName[1] ''a cat'''); 97 Add('Assign AnimalProperty[1] ''It meows and purrs'''); 98 Add('Print ''An animal guessing game.'''); 99 Add('Assign AnimalCount 2'); 100 Add('Repeat'); 101 Add('BeginBlock'); 102 Add('PrintLn ''Think an animal.'''); 103 Add('Assign I 0'); 104 Add('Repeat'); 105 Add('BeginBlock'); 106 Add('Print AnimalProperty[I]'); 107 Add('Print ''? (y/n)'''); 108 Add('InputLn Answer'); 109 Add('IfEqual Answer ''y'''); 110 Add('BeginBlock'); 111 Add('PrintLn ''That''s clear. It is '''); 112 Add('PrintLn AnimalName[I]'); 113 Add('Break'); 114 Add('EndBlock'); 115 Add('Increment I'); 116 Add('IfHigherOrEqual I AnimalCount'); 117 Add('Break'); 118 Add('EndBlock'); 119 Add('PrintLn ''I am lost. What is the animal?'''); 120 Add('InputLn AnimalName[I]'); 121 Add('PrintLn ''Describe the animal for me. What is it like?'''); 122 Add('InputLn AnimalProperty[I]'); 123 Add('PrintLn ''Thank you. I will remember that animal.'''); 124 Add('Increment AnimalCount 1'); 125 Add('PrintLn '''''); 126 Add('EndBlock'); 127 end; 128 } 63 129 end; 64 130 … … 97 163 end; 98 164 165 procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: char); 166 begin 167 if Key = #13 then ButtonSend.Click; 168 end; 169 99 170 procedure TForm1.FormCreate(Sender: TObject); 100 171 begin … … 115 186 begin 116 187 while InputBuffer.Count = 0 do begin 188 if Application.Terminated then Break; 117 189 Sleep(50); 118 190 Application.ProcessMessages; 119 191 end; 120 Result := InputBuffer[0]; 121 InputBuffer.Delete(0); 192 if InputBuffer.Count > 0 then begin 193 Result := InputBuffer[0]; 194 InputBuffer.Delete(0); 195 end else Result := ''; 122 196 end; 123 197
Note:
See TracChangeset
for help on using the changeset viewer.