home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
22rsx
/
byestuff.ark
/
DIAL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-11-23
|
3KB
|
119 lines
PROGRAM dial(access, cmd, input, output);
CONST
maxcodes = 2;
(*$s-*)
cr = (:13:);
(*$s+*)
(*$i'rsxcalls.inc' *)
(*$i'strings.dec' *)
VAR
codes : ARRAY[1..maxcodes] OF string;
stopped : boolean;
access,
cmd : text;
(* initialized strings *)
atz,
atinit,
atdp : string;
(*$l-,i'strings.inc' *)
(*$l+*)
(* 1-----------------1 *)
PROCEDURE putchar(c : char); (* to modem port directly *)
VAR
junk : integer;
BEGIN (* putchar *)
WHILE syscall(moutstat, 0) = 0 DO (* wait *)
junk := syscall(mout, c);
END; (* putchar *)
(* 1-----------------1 *)
PROCEDURE putmdmstring(VAR s : string);
VAR
i : integer;
BEGIN (* putmdmstring *)
i := 1;
WHILE s[i] <> eos DO BEGIN
write(s[i]); putchar(s[i]); i := succ(i); END;
END; (* putmdmstring *)
(* 1-----------------1 *)
PROCEDURE skipblanks(VAR f : text);
BEGIN (* skipblanks *)
WHILE NOT eoln(f) AND (f^ = ' ') DO get(f);
END; (* skipblanks *)
(* 1-----------------1 *)
PROCEDURE setupstrings;
(* sets up long-distance access codes *)
VAR
i : integer;
BEGIN (* setupstrings *)
FOR i := 1 TO maxcodes DO codes[i, 1] := eos;
i := 1;
IF exists(access) THEN
WHILE NOT eof(access) AND (i <= maxcodes) DO BEGIN
readlnstring(access, codes[i]); i := succ(i); END;
(*$s- 123456789o123456789o *)
atdp [1 FOR 4] := 'ATDP'; atdp [ 5] := eos;
atz [1 FOR 3] := 'ATZ'; atz [ 4] := eos;
atinit[1 FOR 16] := 'ATE0Q0V0S0=0M1X1'; atinit[17] := eos;
(*$s+ 123456789o123456789o *)
stringextend(atz, cr, true); stringextend(atinit, cr, true);
END; (* setupstrings *)
(* 1-----------------1 *)
PROCEDURE dialone(VAR f : text);
(* reads the next number and tries to call. Terminates program *)
(* after setting up call if connection successful, else returns *)
BEGIN (* dialone *)
IF odd(status(input) DIV 2) THEN readln;
putmdmstring(atdp);
IF f^ IN ['<', '>'] THEN BEGIN
IF f^ = '<' THEN putmdmstring(codes[1])
ELSE IF f^ = '>' THEN putmdmstring(codes[2]);
write(f^); get(f); END;
WHILE NOT eoln(f) AND (f^ <> ';') DO BEGIN
write(f^); putchar(f^); get(f); END;
IF NOT eoln(f) THEN get(f);
putchar(cr); writeln;
END; (* dialone *)
(* 1-----------------1 *)
BEGIN (* dial *)
IF syscall(RSX, 0) = 0 THEN writeln('BYERSX not running')
ELSE BEGIN
setupstrings;
REPEAT
reset(cmd); skipblanks(cmd);
IF cmd^ = '(' THEN BEGIN
get(cmd);
WHILE NOT eoln(cmd) AND (cmd^ <> ')') DO get(cmd);
IF cmd^= ')' THEN get(cmd);
skipblanks(cmd); END;
stopped := eoln(cmd);
WHILE NOT eoln(cmd) DO BEGIN
dialone(cmd); skipblanks(cmd); END;
UNTIL stopped; END;
END. (* dial *)
S