-
Notifications
You must be signed in to change notification settings - Fork 8
/
STRCOLL.PAS
66 lines (57 loc) · 1.46 KB
/
STRCOLL.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
unit StrColl;
interface
uses Objects;
type
Filename = string;
PStrCollection = ^TStrCollection;
TStrCollection = object( TCollection )
procedure FreeItem( Item : pointer ); virtual;
function Load( f : FileName ) : boolean;
function Save( f : FileName ) : boolean;
end;
implementation
procedure TStrCollection.FreeItem( Item : pointer );
begin
disposeStr( Item );
end;
function TStrCollection.Load( f : Filename ) : boolean;
var
auxF : text;
auxS : string;
begin
assign( auxF, f );
reset( auxF );
if IOResult = 0
then
begin
repeat
readln( auxF, auxS );
if auxS <> ''
then insert( newStr( auxS ));
until eof( auxF ) or (IOresult <> 0);
close( auxF );
Load := TRUE
end
else Load := FALSE
end;
function TStrCollection.Save( f : Filename ) : boolean;
var
auxF : text;
i : word;
begin
assign( auxF, f );
{$I-}
rewrite( auxF );
{$I+}
if IOResult = 0
then
begin
for i := 0 to pred(count) do
if At(i) <> nil
then writeln( auxF, PString(At(i))^ );
close( auxF );
Save := TRUE;
end
else Save := FALSE
end;
end.