- Timestamp:
- Oct 9, 2024, 9:14:47 PM (6 weeks ago)
- Location:
- branches/Independent
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Independent
-
Property svn:ignore
set to
lib
Independent
Independent.lps
Independent.res
-
Property svn:ignore
set to
-
branches/Independent/Api.pas
r64 r65 10 10 11 11 TApi = class 12 procedure PrintHelloWorld; virtual; abstract;12 procedure WriteLine(Text: string); virtual; abstract; 13 13 procedure RunApp(Name: string); virtual; abstract; 14 14 procedure Sleep(Time: TDateTime); virtual; abstract; -
branches/Independent/Apps.pas
r64 r65 32 32 begin 33 33 with Context.Api do begin 34 PrintHelloWorld;34 WriteLine('Hello World!'); 35 35 Sleep(OneSecond); 36 36 RunApp('Code'); … … 49 49 Name := 'Code'; 50 50 Code := TStringList.Create; 51 Code.Add('PrintHelloWorld');52 51 end; 53 52 … … 62 61 I: Integer; 63 62 Line: string; 63 Command: string; 64 Index: Integer; 64 65 begin 65 66 I := 0; 66 67 while (I >= 0) and (I < Code.Count) do begin 67 Line := Code[I] ;68 Line := Code[I].Trim; 68 69 Inc(I); 69 if Line = 'PrintHelloWorld' then Context.Api.PrintHelloWorld; 70 if Line = '' then Continue; 71 72 Index := Pos(' ', Line); 73 if Index > 0 then begin 74 Command := Copy(Line, 1, Index - 1); 75 Delete(Line, 1, Index); 76 end else begin 77 Command := Line; 78 Line := ''; 79 end; 80 if Command = 'WriteLine' then Context.Api.WriteLine(Line) 81 else if Command = 'Sleep' then Context.Api.Sleep(StrToInt(Line)) 82 else if Command = 'RunApp' then Context.Api.RunApp(Line) 83 else raise Exception.Create('Unsupported command ' + Command); 70 84 end; 71 85 end; -
branches/Independent/FormMain.lfm
r64 r65 8 8 ClientWidth = 971 9 9 DesignTimePPI = 144 10 OnCreate = FormCreate 10 11 OnShow = FormShow 11 12 LCLVersion = '3.6.0.0' -
branches/Independent/FormMain.pas
r64 r65 12 12 TFormName = class(TForm) 13 13 Memo1: TMemo; 14 procedure FormCreate(Sender: TObject); 14 15 procedure FormShow(Sender: TObject); 15 16 private 17 FileSystemDir: string; 16 18 System: TSystem; 17 19 procedure ConsoleWrite(Text: string); 20 function LoadFile(Name: string): string; 18 21 public 19 22 … … 33 36 System := TSystem.Create; 34 37 System.Console.OnWrite := ConsoleWrite; 38 System.FileSystem.OnLoadFile := LoadFile; 35 39 System.Start; 40 end; 41 42 procedure TFormName.FormCreate(Sender: TObject); 43 begin 44 FileSystemDir := 'FileSystem'; 36 45 end; 37 46 … … 41 50 end; 42 51 52 function TFormName.LoadFile(Name: string): string; 53 var 54 F: TFileStream; 55 begin 56 F := TFileStream.Create(FileSystemDir + DirectorySeparator + Name, fmOpenRead); 57 try 58 if F.Size > 0 then begin 59 Result := default(string); 60 SetLength(Result, F.Size); 61 F.Read(Result[1], F.Size); 62 end else Result := ''; 63 finally 64 F.Free; 65 end; 66 end; 67 43 68 end. 44 69 -
branches/Independent/Independent.lpi
r64 r65 95 95 <IsPartOfProject Value="True"/> 96 96 </Unit> 97 <Unit> 98 <Filename Value="FileSystem.pas"/> 99 <IsPartOfProject Value="True"/> 100 </Unit> 97 101 </Units> 98 102 </ProjectOptions> -
branches/Independent/Independent.lpr
r64 r65 11 11 {$ENDIF} 12 12 Interfaces, // this includes the LCL widgetset 13 Forms, FormMain, Os, Apps, Api, Console 13 Forms, FormMain, Os, Apps, Api, Console, FileSystem 14 14 { you can add units after this }; 15 15 -
branches/Independent/Os.pas
r64 r65 4 4 5 5 uses 6 Classes, SysUtils, Generics.Collections, DateUtils, Api, Console ;6 Classes, SysUtils, Generics.Collections, DateUtils, Api, Console, FileSystem; 7 7 8 8 type … … 44 44 private 45 45 FName: string; 46 procedure PrintHelloWorldSync; 46 FText: string; 47 procedure WriteLineSync; 47 48 procedure RunAppSync; 48 49 public 49 50 App: TRunningApp; 50 51 System: TSystem; 51 procedure PrintHelloWorld; override;52 procedure WriteLine(Text: string); override; 52 53 procedure RunApp(Name: string); override; 53 54 procedure Sleep(Time: TDateTime); override; … … 58 59 TSystem = class 59 60 Console: TConsole; 61 FileSystem: TFileSystem; 60 62 Apps: TApps; 61 63 RunningApps: TRunningApps; … … 124 126 { TSystemApi } 125 127 126 procedure TSystemApi. PrintHelloWorldSync;127 begin 128 System.Console.Write(App.App.Name + ': Hello world!');128 procedure TSystemApi.WriteLineSync; 129 begin 130 System.Console.Write(App.App.Name + ': ' + FText); 129 131 end; 130 132 … … 134 136 end; 135 137 136 procedure TSystemApi.PrintHelloWorld; 137 begin 138 App.AppThread.Synchronize(PrintHelloWorldSync); 138 procedure TSystemApi.WriteLine(Text: string); 139 begin 140 FText := Text; 141 App.AppThread.Synchronize(WriteLineSync); 139 142 end; 140 143 … … 165 168 166 169 procedure TSystem.Start; 167 begin 170 var 171 AppCode: TAppCode; 172 begin 173 Apps.AddNew(TAppTest); 174 AppCode := TAppCode(Apps.AddNew(TAppCode)); 175 AppCode.Code.Text := FileSystem.LoadFile('Code.exe'); 176 168 177 RunApp('Test'); 169 178 RunApp('Test'); … … 174 183 begin 175 184 Console := TConsole.Create; 185 FileSystem := TFileSystem.Create; 176 186 RunningApps := TRunningApps.Create; 177 187 Apps := TApps.Create; 178 Apps.AddNew(TAppTest);179 Apps.AddNew(TAppCode);180 188 end; 181 189 … … 185 193 FreeAndNil(RunningApps); 186 194 FreeAndNil(Console); 195 FreeAndNil(FileSystem); 187 196 inherited; 188 197 end;
Note:
See TracChangeset
for help on using the changeset viewer.