Line | |
---|
1 | unit Console;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils;
|
---|
7 |
|
---|
8 | type
|
---|
9 | TWriteEvent = procedure (Text: string) of object;
|
---|
10 | TReadEvent = function: string of object;
|
---|
11 |
|
---|
12 | { TConsole }
|
---|
13 |
|
---|
14 | TConsole = class
|
---|
15 | private
|
---|
16 | FOnRead: TReadEvent;
|
---|
17 | FOnWrite: TWriteEvent;
|
---|
18 | public
|
---|
19 | procedure Write(Text: string);
|
---|
20 | function Read: string;
|
---|
21 | published
|
---|
22 | property OnWrite: TWriteEvent read FOnWrite write FOnWrite;
|
---|
23 | property OnRead: TReadEvent read FOnRead write FOnRead;
|
---|
24 | end;
|
---|
25 |
|
---|
26 |
|
---|
27 | implementation
|
---|
28 |
|
---|
29 | { TConsole }
|
---|
30 |
|
---|
31 | procedure TConsole.Write(Text: string);
|
---|
32 | begin
|
---|
33 | if Assigned(FOnWrite) then FOnWrite(Text);
|
---|
34 | end;
|
---|
35 |
|
---|
36 | function TConsole.Read: string;
|
---|
37 | begin
|
---|
38 | if Assigned(FOnRead) then Result := FOnRead
|
---|
39 | else Result := '';
|
---|
40 | end;
|
---|
41 |
|
---|
42 | end.
|
---|
43 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.