source: branches/Independent/Apps/Code/AppCode.pas

Last change on this file was 67, checked in by chronos, 3 weeks ago
  • Modified: Apps split into separate units.
  • Modified: SystemApi moved into separate unit.
File size: 1.4 KB
Line 
1unit AppCode;
2
3interface
4
5uses
6 Classes, SysUtils, Api;
7
8type
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
19implementation
20
21{ TAppCode }
22
23constructor TAppCode.Create;
24begin
25 Name := 'Code';
26 Code := TStringList.Create;
27end;
28
29destructor TAppCode.Destroy;
30begin
31 FreeAndNil(Code);
32 inherited;
33end;
34
35procedure TAppCode.Run(Context: TAppContext);
36var
37 I: Integer;
38 Line: string;
39 Command: string;
40 Index: Integer;
41begin
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;
65end;
66
67end.
68
Note: See TracBrowser for help on using the repository browser.