6
{ Possible error codes returned to DOS by this program }
12
(*************************************************************************)
13
(* Create a stream error procedure which will be called on error of the *)
14
(* stream. Will Terminate executing program, as well as display info *)
15
(* on the type of error encountered. *)
16
(*************************************************************************)
17
Procedure StreamErrorProcedure(Var S: TStream); FAR;
19
If S.Status = StError then
21
WriteLn('ERROR: General Access failure. Halting');
24
If S.Status = StInitError then
26
Write('ERROR: Cannot Init Stream. Halting. ');
27
{ SPECIFIC TO DOS STREAMS }
29
2: WriteLn('File not found.');
30
3: WriteLn('Path not found.');
31
5: Writeln('Access denied.');
37
If S.Status = StReadError then
39
WriteLn('ERROR: Read beyond end of Stream. Halting');
42
If S.Status = StWriteError then
44
WriteLn('ERROR: Cannot expand Stream. Halting');
47
If S.Status = StGetError then
49
WriteLn('ERROR: Get of Unregistered type. Halting');
52
If S.Status = StPutError then
54
WriteLn('ERROR: Put of Unregistered type. Halting');
59
Procedure WriteInformation;
60
{ Writes information about the program }
62
WriteLn('Usage: fname.ext to check');
66
{ Program to demonstrate the TDosStream object. }
69
Const S : String = '0123456789';
70
P : Pchar = '9876543210';
72
Var Stream : TDosStream;
78
StreamError:= @StreamErrorProcedure;
79
Writeln ('Writing to stream : "01234567899876543210"');
80
Stream.Init('testobj.tmp',stCreate);
83
Writeln ('Closing stream.');
85
Writeln ('Reading from stream : ');
86
Stream.Init('testobj.tmp',StOpenRead);
87
WriteLn('After opening');
88
Writeln ('Reading (',S,') : ',Stream.ReadStr^);
89
Writeln ('Reading (',P,') : ',Stream.StrRead);
90
Writeln ('Closing stream.');
92
Writeln ('Same thing, using raw read method : ');
93
Writeln ('Reading from stream : ');
94
Stream.Init('testobj.tmp',StOpenRead);
96
Writeln ('Reading (',S,') : ',Buf);
98
Stream.Read (Buf[1],L);
100
Writeln ('Reading (',P,') : ',Buf);
101
Writeln ('Closing stream.');
103
Writeln ('Statistics about stream : ');
104
Stream.Init('testobj.tmp',StOpenRead);
105
Writeln ('Size : ',Stream.GetSize);
106
Writeln ('Position : ',Stream.GetPos);
107
Writeln ('Reading (',S,') : ',Stream.ReadStr^);
109
Writeln ('Position : ',L);
110
Writeln ('Closing stream.');
112
Writeln ('Reading from stream : ');
113
Stream.Init('testobj.tmp',StOpenRead);
114
Writeln ('Seek to position :',L);
116
Writeln ('Reading (',P,') : ',Stream.StrRead);
117
Writeln ('Closing stream.');
119
Writeln ('Truncating stream to zero length.');
120
Stream.Init('testobj.tmp',StOpenWrite);
123
Assign(f,'testobj.tmp');