-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSSFILE.PAS
146 lines (122 loc) · 3.13 KB
/
SSFILE.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
Unit SSFile;
Interface
Uses
Crt, Dos, SSType, SSTrans;
Function FileSave (Prog : TProgPtr; FileName : String) : String;
Function FileLoad (Prog : TProgPtr; FileName : String) : String;
Implementation
{*
* FileLoad
*
* Arguments
* Prog : TProgPtr - A pointer to the main program's data structure.
* FileName : String - The name of the file that is to be loaded.
*
* Opens and reads FileName and assigns all it's data into the variables
* in Prog.
*}
Function FileLoad (Prog : TProgPtr; FileName : String) : String;
Var
F : Text;
X, Y : Integer;
Begin
FileLoad:= GTS ('File loaded sucessfully.');
If (FileName='') then
Begin
Exit;
End;
Assign (F, FileName);
Case DosError of
2: FileLoad:= GTS ('File not found.');
3: FileLoad:= GTS ('Path not found.');
5: FileLoad:= GTS ('Access denied.');
6: FileLoad:= GTS ('Invalid handle.');
8: FileLoad:= GTS ('Not enough memory.');
10: FileLoad:= GTS ('Invalid environment.');
11: FileLoad:= GTS ('Invalid format.');
18: FileLoad:= GTS ('No more files.');
End;
If (DosError>0) then Exit;
{$I-}
Reset (F);
{$I+}
If (IOResult<>0) then
Begin
FileLoad:= GTS ('File not found.');
Exit;
End;
For Y:=1 to LinesMaximum do
Begin
Readln (F, Prog^.LineDimension[Y]);
End;
For X:=1 to ColumnsMaximum do
Begin
Readln (F, Prog^.ColumnDimension[X]);
End;
For Y:=1 to LinesMaximum do
Begin
For X:=1 to ColumnsMaximum do
Begin
Readln (F, Prog^.Cell[Y, X].Value);
Readln (F, Prog^.Cell[Y, X].TextAlignment);
Readln (F, Prog^.Cell[Y, X].ForegroundColor);
Readln (F, Prog^.Cell[Y, X].BackgroundColor);
End;
End;
Close (F);
End;
{*
* FileSave
*
* Arguments
* Prog : TProgPtr - A pointer to the main program's data structure.
* FileName : String - The name of the file that is to be loaded.
*
* Opens and clears (if it already exists) FileName and writes all the
* information about the current document into the file.
*}
Function FileSave (Prog : TProgPtr; FileName : String) : String;
Var
F : Text;
X, Y : Integer;
Begin
FileSave:= GTS ('File saved sucessfully.');
If (FileName='') then
Begin
Exit;
End;
Assign (F, FileName);
Case DosError of
2: FileSave:= GTS ('File not found.');
3: FileSave:= GTS ('Path not found.');
5: FileSave:= GTS ('Access denied.');
6: FileSave:= GTS ('Invalid handle.');
8: FileSave:= GTS ('Not enough memory.');
10: FileSave:= GTS ('Invalid environment.');
11: FileSave:= GTS ('Invalid format.');
18: FileSave:= GTS ('No more files.');
End;
If (DosError>0) then Exit;
Rewrite (F);
For Y:=1 to LinesMaximum do
Begin
Writeln (F, Prog^.LineDimension[Y]);
End;
For X:=1 to ColumnsMaximum do
Begin
Writeln (F, Prog^.ColumnDimension[X]);
End;
For Y:=1 to LinesMaximum do
Begin
For X:=1 to ColumnsMaximum do
Begin
Writeln (F, Prog^.Cell[Y, X].Value);
Writeln (F, Prog^.Cell[Y, X].TextAlignment);
Writeln (F, Prog^.Cell[Y, X].ForegroundColor);
Writeln (F, Prog^.Cell[Y, X].BackgroundColor);
End;
End;
Close (F);
End;
Begin
End.