home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
n
/
newscr.zip
/
NEWSCR.EXE
/
PHONE.SCR
< prev
next >
Wrap
Text File
|
1992-08-28
|
5KB
|
204 lines
!---------------------------------------------------------------------!
! !
! Copyright (c) 1991 !
! by CompuServe Incorporated, Columbus, Ohio !
! !
! The information in this software is subject to change without !
! notice and should not be construed as a commitment by CompuServe. !
! !
! PHONE Script: !
! Phone Script: Contains modem/phone related logic. !
! Success: returns %Success !
! Failure: saves error msg in %FailureMsg and returns %Failure !
! !
! $Revision:: 1.9 $ !
! !
!---------------------------------------------------------------------!
WaitTime = 10;
goto Do_Phone_Connect;
!------------------------!
! Subroutines !
!------------------------!
Send_Modem_Cmd:
if (ModemStr = "") goto End_Modem_Cmd;
sendm %mdm_Prefix;
sendm ModemStr;
sendm %mdm_Suffix;
End_Modem_Cmd:
return;
Hangup_Before_Connect:
define %LOCAL = 2;
call %Dir & "disconct.scr" () : Result;
return;
Two_Tries_Hangup:
gosub Hangup_Before_Connect;
goto Send_Reset_String;
!----------------------------------------!
! Main Program: Start_Connect !
!----------------------------------------!
Do_Phone_Connect:
RingLimit = 5;
RingCount = 0;
UsingModem = %FALSE;
on cancel goto Phone_Cancelled;
if %DialType = 0 goto Get_Tone_Str;
DialTypeStr = %mdm_Pulse_Dial; ! Type = DT_Pulse
goto Init_Modem;
Get_Tone_Str:
DialTypeStr = %mdm_Tone_Dial; ! Type = DT_Tone
Init_Modem:
show "Initializing Modem";
MsgStr = "Dialing " & %Phone;
tries = 0;
Send_Reset_String:
ModemStr = %mdm_Reset;
gosub Send_Modem_Cmd;
wait
%mdm_Ack goto Modem_OK,
"0" goto Modem_OK
until 40;
tries = tries + 1;
if tries = 2 goto Two_Tries_Hangup; !Two failures to send Reset -
!hang up and try twice more.
if tries < 4 goto Send_Reset_String;
wait until WaitTime;
FailStr = "Modem not responding";
goto Phone_Failed;
Modem_OK:
wait until WaitTime;
if (%mdm_Init = "") goto Check_Modem_Speaker;
sendm %mdm_Init;
wait
%mdm_Ack goto End_Wait1
until 33;
End_Wait1:
wait until WaitTime;
Check_Modem_Speaker:
if (%mdm_Speaker <> 0) goto Try_Phone;
sendm %mdm_Prefix;
sendm "M0";
send %CR;
wait
%mdm_Ack goto End_Wait2
until 33;
End_Wait2:
wait until WaitTime;
Try_Phone:
count = 0;
FailStr = "";
Dial_Phone:
if (count > %Retry) goto Phone_Failed;
show MsgStr;
ModemStr = DialTypeStr & %Phone;
gosub Send_Modem_Cmd;
Start_Phone_Loop:
wait
%mdm_Success goto Modem_Success,
%mdm_Failure goto Modem_Failure,
"No Dial" goto No_Dial_Tone,
"Dial Complete" goto Dial_Complete,
"Busy" goto Line_Busy,
"Ring" goto Remote_Ring
until 556;
FailStr = "Dialing failed";
goto Exit_Failure;
Modem_Success:
wait until 2 * WaitTime;
exit %Success;
Modem_Failure:
FailStr = "Dialing unsuccessful, check phone number";
wait until WaitTime;
goto End_Phone_Loop;
No_Dial_Tone:
FailStr = "No Dial";
goto Phone_Failed;
Dial_Complete:
MsgStr = "Dialed " & %Phone & ", awaiting answer";
show MsgStr;
goto Start_Phone_Loop;
Line_Busy:
FailStr = "Number is busy";
wait until 2 * WaitTime;
send %CR;
wait
%mdm_Success goto End_Line_Busy,
%mdm_Failure goto End_Line_Busy,
"No Dial" goto End_Line_Busy,
"Dial Complete" goto End_Line_Busy,
"Busy" goto End_Line_Busy,
"Ring" goto End_Line_Busy
until 56;
End_Line_Busy:
wait until WaitTime;
goto End_Phone_Loop;
Remote_Ring:
if RingCount <= RingLimit goto Show_Ringing;
FailStr = "No answer";
goto End_Phone_Loop;
Show_Ringing:
MsgStr = %Phone & " is ringing, awaiting answer";
show MsgStr;
goto Start_Phone_Loop;
End_Phone_Loop:
MsgStr = FailStr & ", redialing " & %Phone;
count = count + 1;
goto Dial_Phone;
Phone_Cancelled:
gosub Hangup_Before_Connect;
exit Result;
Phone_Failed:
if FailStr <> "" goto Exit_Failure;
FailStr = "Dialing failed";
Exit_Failure:
define %FailureMsg = FailStr;
exit %Failure;