-
Notifications
You must be signed in to change notification settings - Fork 0
/
LAN2LAN.PAS
298 lines (250 loc) · 6.05 KB
/
LAN2LAN.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
program LAN2LAN;
uses Crt, Dos;
var
File1 : text;
File2 : text;
Key : char;
Line1 : string;
Line2 : string;
Station : integer;
count : integer;
Temp2 : string;
Row1 : integer;
Row2 : integer;
finished : boolean;
Hour,
Minute,
Second,
Sec100 : word;
function Exist(FileName : string) : boolean;
var
InFile : text;
begin
Assign(InFile, FileName);
{$I-}
Reset(InFile);
{$I+}
if IOResult <> 0 then
Exist := FALSE
else
begin
Exist := TRUE;
Close(InFile);
end;
end;
procedure ShowError;
var
BLANK : char;
begin
Window(1,1,80,25);
GotoXY(1,25);
TextColor(lightred);
Write('The other chat mode has been terminated by the other user.');
Sound(1200);
Delay(200);
NoSound;
Delay(4000);
Window(1,3,80,25);
TextColor(cyan);
ClrScr;
WriteLn('The chat session has been terminated.');
WriteLn;
WriteLn('Thank you for using the LAN2LAN communications software!');
WriteLn('(c)Copyright 1994 by Nathan Thomas');
WriteLn;
TextColor(lightgray);
Delay(3000);
if ((Station = 1) and Exist('TALK1.FLE')) or ((Station = 2) and Exist('TALK2.FLE')) then
Erase(File1);
Halt(1);
end;
procedure SingleInput;
begin
while (not KEYPRESSED) and (not finished) do
begin
finished := FALSE;
Window(1,3,80,12);
if (Length(Line1) < 80) then
GotoXY(1+Length(Line1),Row1)
else
GotoXY(1+(Length(Line1)-80),Row1+1);
if (((1+(Length(Line1)-80)+Row1) > 10)) then
GotoXY(1,10);
Delay(100);
if ((Station = 1) and Exist('TALK2.FLE')) or ((Station = 2) and Exist('TALK1.FLE')) then
begin
Reset(File2);
ReadLn(File2,Line2);
Close(File2);
end
else
ShowError;
if Line2 <> Temp2 then
begin
Window(1,14,80,23);
TextColor(red);
GotoXY(1,Row2);
WriteLn(Line2);
Temp2 := Line2;
if Length(Line2) > 80 then Row2 := Row2 + 2
else Row2 := Row2 + 1;
if Length(Line2) > 160 then
Row2 := Row2 + 2;
if Row2 > 10 then
Row2 := 10;
end;
GetTime(Hour, Minute, Second, Sec100);
if (Second >= 0) and (Second <= 1) then
begin
if Hour > 12 then
Hour := Hour - 12;
Window(73,1,79,1);
ClrScr;
TextColor(cyan);
Write(Hour,':',Minute);
end;
end;
Key := ReadKey;
if Key = #27 then
begin
finished := TRUE;
Line1 := '';
end;
if Key <> #8 then
begin
if Key <> #13 then
begin
Line1 := Line1 + Key;
Window(1,3,80,12);
GotoXY(1,Row1);
TextColor(yellow);
Write(Line1);
if Key <> #27 then finished := FALSE;
end
else
begin
Rewrite(File1);
Writeln(File1, Line1);
Close(File1);
Window(1,3,80,12);
if (Length(Line1) < 80) then
GotoXY(1+Length(Line1),Row1)
else
GotoXY(1+(Length(Line1)-80),Row1+1);
WriteLn;
if Length(Line1) > 80 then
Row1 := Row1 + 2
else
Row1 := Row1 + 1;
if Length(Line1) > 160 then
Row1 := Row1 + 1;
if Row1 > 10 then
Row1 := 10;
Line1 := '';
end;
end
else
begin
Line1 := Copy(Line1, 1, (Length(Line1)-1));
Window(1,3,80,12);
GotoXY(1,Row1);
TextColor(yellow);
Write(Line1,' ');
end;
end;
begin
TextColor(lightgray);
TextBackground(black);
ClrScr;
WriteLn;
Write('* Initializing the LAN2LAN communications software, ',GetEnv('ID'),'.');
if Exist('TALK1.FLE') then
Station := 2
else
Station := 1;
if Station = 1 then
begin
Assign(File1,'TALK1.FLE');
Assign(File2,'TALK2.FLE');
end
else
begin
Assign(File1,'TALK2.FLE');
Assign(File2,'TALK1.FLE');
Rewrite(File2);
Close(File2);
end;
Rewrite(File1);
Close(File1);
WriteLn;
Write('* Waiting for connection on Station #',Station,' -- <ESC> to cancel.');
repeat
Delay(1000);
if KEYPRESSED then
if ReadKey = #27 then
begin
WriteLn;
TextColor(cyan);
WriteLn('The chat session has been terminated.');
WriteLn;
WriteLn('Thank you for using the LAN2LAN communications software!');
WriteLn('(c)Copyright 1994 by Nathan Thomas');
WriteLn;
TextColor(lightgray);
Delay(3000);
if ((Station = 1) and Exist('TALK1.FLE')) or ((Station = 2) and Exist('TALK2.FLE')) then
Erase(File1);
Halt(1);
end;
until ((Station = 1) and (Exist('TALK2.FLE'))) or ((Station = 2) and (Exist('TALK1.FLE')));
Row1 := 1;
Row2 := 1;
ClrScr;
TextColor(green);
WriteLn('LAN2LAN * by Nathan Thomas');
Write('* Local ');
for count := 1 to 72 do
Write('*');
GotoXY(1,13);
Write('* Remote ');
for count := 1 to 71 do
Write('*');
GotoXY(1,24);
for count := 1 to 80 do
Write('*');
GotoXY(1,25);
Write('To quit, type <ESC>');
GetTime(Hour, Minute, Second, Sec100);
Window(73,1,79,1);
ClrScr;
TextColor(cyan);
if Hour > 12 then
Hour := Hour - 12;
Write(Hour,':',Minute);
if Station = 1 then
begin
TextColor(lightblue);
Window(67,1,71,1);
Write('HOST');
end;
Line1 := '';
Line2 := '';
Temp2 := '';
Window(1,3,80,12);
repeat
TextColor(yellow);
SingleInput;
until finished;
Window(1,3,80,25);
TextColor(cyan);
ClrScr;
WriteLn('The chat session has been terminated.');
WriteLn;
WriteLn('Thank you for using the LAN2LAN communications software!');
WriteLn('(c)Copyright 1994 by Nathan Thomas');
WriteLn;
TextColor(lightgray);
Delay(3000);
if ((Station = 1) and Exist('TALK1.FLE')) or ((Station = 2) and Exist('TALK2.FLE')) then
Erase(File1);
end.