|
Last change
on this file was 53, checked in by chronos, 2 years ago |
- Added: Experimental textos computer.
|
|
File size:
807 bytes
|
| Line | |
|---|
| 1 | unit UShell;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, UApp;
|
|---|
| 9 |
|
|---|
| 10 | type
|
|---|
| 11 |
|
|---|
| 12 | { TAppShell }
|
|---|
| 13 |
|
|---|
| 14 | TAppShell = class(TApp)
|
|---|
| 15 | Line: string;
|
|---|
| 16 | procedure OnStart; override;
|
|---|
| 17 | procedure OnTerminate; override;
|
|---|
| 18 | procedure OnInputText; override;
|
|---|
| 19 | end;
|
|---|
| 20 |
|
|---|
| 21 | implementation
|
|---|
| 22 |
|
|---|
| 23 | { TAppShell }
|
|---|
| 24 |
|
|---|
| 25 | procedure TAppShell.OnStart;
|
|---|
| 26 | begin
|
|---|
| 27 | Api.OutputText('Supershell' + LineEnding);
|
|---|
| 28 | end;
|
|---|
| 29 |
|
|---|
| 30 | procedure TAppShell.OnTerminate;
|
|---|
| 31 | begin
|
|---|
| 32 | Api.OutputText('Shell exited');
|
|---|
| 33 | end;
|
|---|
| 34 |
|
|---|
| 35 | procedure TAppShell.OnInputText;
|
|---|
| 36 | var
|
|---|
| 37 | Text: string;
|
|---|
| 38 | begin
|
|---|
| 39 | Text := Api.InputText;
|
|---|
| 40 | Api.OutputText(Text);
|
|---|
| 41 | if Text[1] = #13 then begin
|
|---|
| 42 | if Line = 'exit' then Terminate
|
|---|
| 43 | else begin
|
|---|
| 44 | Api.OutputText(LineEnding + 'Executing ' + Line + LineEnding);
|
|---|
| 45 | Api.ExecuteApp(Line);
|
|---|
| 46 | end;
|
|---|
| 47 | Line := '';
|
|---|
| 48 | end else Line := Line + Text;
|
|---|
| 49 | end;
|
|---|
| 50 |
|
|---|
| 51 | end.
|
|---|
| 52 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.