|
Last change
on this file was 67, checked in by chronos, 12 months ago |
- Modified: Apps split into separate units.
- Modified: SystemApi moved into separate unit.
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | unit AppCode;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, Api;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 | { TAppCode }
|
|---|
| 10 |
|
|---|
| 11 | TAppCode = class(TApp)
|
|---|
| 12 | Code: TStringList;
|
|---|
| 13 | constructor Create; override;
|
|---|
| 14 | destructor Destroy; override;
|
|---|
| 15 | procedure Run(Context: TAppContext); override;
|
|---|
| 16 | end;
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | implementation
|
|---|
| 20 |
|
|---|
| 21 | { TAppCode }
|
|---|
| 22 |
|
|---|
| 23 | constructor TAppCode.Create;
|
|---|
| 24 | begin
|
|---|
| 25 | Name := 'Code';
|
|---|
| 26 | Code := TStringList.Create;
|
|---|
| 27 | end;
|
|---|
| 28 |
|
|---|
| 29 | destructor TAppCode.Destroy;
|
|---|
| 30 | begin
|
|---|
| 31 | FreeAndNil(Code);
|
|---|
| 32 | inherited;
|
|---|
| 33 | end;
|
|---|
| 34 |
|
|---|
| 35 | procedure TAppCode.Run(Context: TAppContext);
|
|---|
| 36 | var
|
|---|
| 37 | I: Integer;
|
|---|
| 38 | Line: string;
|
|---|
| 39 | Command: string;
|
|---|
| 40 | Index: Integer;
|
|---|
| 41 | begin
|
|---|
| 42 | I := 0;
|
|---|
| 43 | while (I >= 0) and (I < Code.Count) do begin
|
|---|
| 44 | Line := Code[I].Trim;
|
|---|
| 45 | Inc(I);
|
|---|
| 46 | if Line = '' then Continue;
|
|---|
| 47 |
|
|---|
| 48 | Index := Pos(' ', Line);
|
|---|
| 49 | if Index > 0 then begin
|
|---|
| 50 | Command := Copy(Line, 1, Index - 1);
|
|---|
| 51 | Delete(Line, 1, Index);
|
|---|
| 52 | end else begin
|
|---|
| 53 | Command := Line;
|
|---|
| 54 | Line := '';
|
|---|
| 55 | end;
|
|---|
| 56 | if Command = 'WriteLine' then Context.Api.WriteLine(Line)
|
|---|
| 57 | else if Command = 'Sleep' then Context.Api.Sleep(StrToInt(Line))
|
|---|
| 58 | else if Command = 'RunApp' then Context.Api.RunApp(Line)
|
|---|
| 59 | else if Command = 'CreateWindow' then Context.Api.CreateWindow
|
|---|
| 60 | //else if Command = 'SetWindowName' then Context.Api.SetWindowName
|
|---|
| 61 | //else if Command = 'SetWindowRect' then Context.Api.SetWindowRect(Name, Rect)
|
|---|
| 62 | //else if Command = 'SetWindowVisible' then Context.Api.SetWindowVisible
|
|---|
| 63 | else raise Exception.Create('Unsupported command ' + Command);
|
|---|
| 64 | end;
|
|---|
| 65 | end;
|
|---|
| 66 |
|
|---|
| 67 | end.
|
|---|
| 68 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.