Changeset 150 for branches/easy compiler/UFormMain.pas
- Timestamp:
- Jan 18, 2018, 2:36:23 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/easy compiler/UFormMain.pas
r149 r150 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 UTargetCode, USourceCode, USourceExecutor, USourceGenerator, LCLIntf; 9 UTargetCode, USourceCode, USourceExecutor, USourceGenerator, LCLIntf, 10 ComCtrls; 10 11 11 12 type … … 14 15 15 16 TForm1 = class(TForm) 17 ButtonBuild: TButton; 16 18 ButtonSend: TButton; 17 ButtonBuild: TButton;18 19 Edit1: TEdit; 19 20 Label1: TLabel; … … 21 22 Label3: TLabel; 22 23 Label4: TLabel; 24 MemoGenerator: TMemo; 23 25 MemoOutput: TMemo; 24 26 MemoSource: TMemo; 25 MemoGenerator: TMemo; 27 PageControl1: TPageControl; 28 TabSheetExecutor: TTabSheet; 29 TabSheetGenerator: TTabSheet; 26 30 procedure ButtonBuildClick(Sender: TObject); 27 31 procedure ButtonSendClick(Sender: TObject); 28 32 procedure Edit1KeyPress(Sender: TObject; var Key: char); 33 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 29 34 procedure FormCreate(Sender: TObject); 30 35 procedure FormDestroy(Sender: TObject); … … 35 40 function ExecutorInput: string; 36 41 public 42 FileName: string; 37 43 end; 38 44 … … 51 57 procedure TForm1.FormShow(Sender: TObject); 52 58 begin 53 { with MemoSource.Lines do begin 54 Add('Begin'); 55 Add('var I Integer'); 56 Add('Assign I 10'); 57 Add('Repeat'); 58 Add('Begin'); 59 Add('PrintLn I'); 60 Add('Decrement I 1'); 61 Add('IfEqual I 0'); 62 Add('Break'); 63 Add('End'); 64 Add('End'); 65 end; 66 with MemoSource.Lines do begin 67 Add('PrintLn ''Super Calculator'''); 68 Add('var Value1 Integer'); 69 Add('var Value2 Integer'); 70 Add('var Result Integer'); 71 Add('Print ''Enter value 1: '''); 72 Add('Assign Value1 0'); 73 Add('InputLn Value1'); 74 Add('Print ''Enter value 2: '''); 75 Add('Assign Value2 0'); 76 Add('InputLn Value2'); 77 78 Add('Assign Result Value1'); 79 Add('Increment Result Value2'); 80 Add('Print ''Sum of two values is: '''); 81 Add('PrintLn Result'); 82 end; 83 with MemoSource.Lines do begin 84 Add('PrintLn ''Hello World!'''); 85 Add('print ''Hello'' PRINT '' World!'''); 86 Add('PrintLn ''Live your life.'''); 87 Add('var Text1 String'); 88 Add('Assign Text1 ''Live your life.'''); 89 Add('var Text2 String'); 90 Add('Assign Text2 ''Live your life.'''); 91 Add('PrintLn Text1'); 92 Add('PrintLn Text2'); 93 94 Add('var Value1 Integer'); 95 Add('Assign Value1 123'); 96 Add('Increment Value1 2'); 97 Add('PrintLn Value1'); 98 99 Add('var Text3 String'); 100 Add('Assign Text3 '''''); 101 Add('Print ''Enter your name:'''); 102 Add('InputLn Text3'); 103 Add('PrintLn Text3'); 104 end; 105 } 106 with MemoSource.Lines do begin 107 Add('Begin'); 108 Add('Var AnimalName StringArray'); 109 Add('Var AnimalProperty StringArray'); 110 Add('Var AnimalCount Integer'); 111 Add('Var Answer String'); 112 Add('Var I Integer'); 113 Add('Assign AnimalName[0] ''an elephant'''); 114 Add('Assign AnimalProperty[0] ''It is big and slow'''); 115 Add('Assign AnimalName[1] ''a cat'''); 116 Add('Assign AnimalProperty[1] ''It meows and purrs'''); 117 Add('Print ''An animal guessing game.'''); 118 Add('Assign AnimalCount 2'); 119 Add('Repeat'); 120 Add('Begin'); 121 Add('PrintLn ''Think an animal.'''); 122 Add('Assign I 0'); 123 Add('Repeat'); 124 Add('Begin'); 125 Add('Print AnimalProperty[I]'); 126 Add('Print ''? (y/n)'''); 127 Add('InputLn Answer'); 128 Add('IfEqual Answer ''y'''); 129 Add('Begin'); 130 Add('Print ''Thats clear. It is '''); 131 Add('PrintLn AnimalName[I]'); 132 Add('Break'); 133 Add('End'); 134 Add('Increment I 1'); 135 Add('IfEqual I AnimalCount'); 136 Add('Break'); 137 Add('End'); 138 Add('IfEqual I AnimalCount'); 139 Add('Begin'); 140 Add('PrintLn ''I am lost. What is the animal?'''); 141 Add('InputLn AnimalName[I]'); 142 Add('PrintLn ''Describe the animal for me. What is it like?'''); 143 Add('InputLn AnimalProperty[I]'); 144 Add('PrintLn ''Thank you. I will remember that animal.'''); 145 Add('Increment AnimalCount 1'); 146 Add('End'); 147 Add('Print ''Do you want to try again? (y/n)'''); 148 Add('InputLn Answer'); 149 Add('IfNotEqual Answer ''y'''); 150 Add('Break'); 151 Add('PrintLn '''''); 152 Add('End'); 153 Add('PrintLn ''Bye'''); 154 Add('End'); 155 end; 156 59 FileName := 'Examples' + DirectorySeparator + 'Animal guessing game.lan'; 60 MemoSource.Lines.LoadFromFile(FileName); 157 61 end; 158 62 … … 196 100 end; 197 101 102 procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction); 103 begin 104 MemoSource.Lines.SaveToFile(FileName); 105 end; 106 198 107 procedure TForm1.FormCreate(Sender: TObject); 199 108 begin
Note:
See TracChangeset
for help on using the changeset viewer.