home *** CD-ROM | disk | FTP | other *** search
- !+N
- CompuServe = 1; ! "CompuServe"
- !-N
-
-
- define %CR = "^M";
- define %FALSE = 0;
- define %TRUE = 1;
-
- dial = 0;
- if %Connected = 1 goto Do_CIS_Script;
- UsingModem = %FALSE;
- init %Port, %BaudRate;
- if %_init goto Continue_Connect;
-
- define %Result = 14;
- goto Connect_Failure;
-
- Continue_Connect:
- Result = %Failure;
- on cancel goto Cancel_Connect;
-
- !! DIAL the PHONE
-
- gosub phone;
- if Result = %Cancel goto Cancel_Connect;
- if Result = %Failure goto Connect_Failure;
- UsingModem = %TRUE;
-
-
- !! Negotiate the Network and Logon
-
- Connect_CIS:
- send %CR;
-
- Do_CIS_Script:
- Result = %Failure;
- gosub login;
-
- Back_From_Login:
- if Result = %Failure goto Connect_Failure;
- if Result = %Cancel goto Cancel_Connect;
- exit %Success;
-
- Connect_Failure:
- if %Connected = 1 goto Connect_Failure_Exit;
- !! if UsingModem goto Hangup_Connect;
- goto Hangup_Connect;
-
- Connect_Failure_Exit:
- reset;
- exit %Failure;
-
- Hangup_Connect:
- dial = 1;
- gosub phone;
- reset;
- exit %Failure;
-
- Cancel_Connect:
- if %Connected = 1 goto CC_1;
- if UsingModem = %FALSE goto CC_1;
- gosub Hangup;
- CC_1:
- define %Result = 12;
- reset;
- exit %Cancel;
-
-
-
- !! SUBCOMMANDS for DIALING and HANGING UP
-
- phone:
- WaitTime = 10;
-
- if dial = 0 goto Do_Phone_Connect;
- gosub Hangup;
- return; ! from GOSUB
-
- Send_Modem_Cmd:
- if (ModemStr = "") goto End_Modem_Cmd;
-
- sendm %mdm_Prefix;
- send ModemStr;
- sendm %mdm_Suffix;
-
- End_Modem_Cmd:
- return; ! from GOSUB
-
- Hangup:
- HangupDone = %FALSE;
- if UsingModem goto Send_Escape;
- goto Send_Hangup;
-
- Send_Escape:
- wait until 12;
- sendm %mdm_EscapeCode;
- wait until 12;
- wait
- %mdm_Ack goto End_Escape_Wait,
- "DISCONNECT" goto Hangup_Complete,
- "CARRIER LOST" goto Hangup_Complete
- until 10;
-
- End_Escape_Wait:
- wait until 2;
-
- Send_Hangup:
- ModemStr = %mdm_Hangup;
- gosub Send_Modem_Cmd;
- wait
- %mdm_Ack goto Pause_And_Return,
- "DISCONNECT" goto Pause_And_Return
- until 20; !! (10 is not enough for some modems to hang up)
- if HangupDone goto Pause_And_Return;
- HangupDone = %TRUE;
- goto Send_Escape;
-
- Pause_And_Return:
- wait until 2;
-
- Hangup_Complete:
- return;
-
- 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;
- goto Init_Modem;
-
- Get_Tone_Str:
- DialTypeStr = %mdm_Tone_Dial;
-
- Init_Modem:
- show "Initializing Modem";
- MsgStr = "Dialing " & %Phone;
- ModemStr = %mdm_Reset;
- gosub Send_Modem_Cmd;
- wait
- %mdm_Ack goto Modem_OK,
- "0" goto Modem_OK
- until 40;
- gosub Hangup;
- wait until 2;
-
- ModemStr = %mdm_Reset;
- gosub Send_Modem_Cmd;
- wait
- %mdm_Ack goto Modem_OK,
- "0" goto Modem_OK
- until 40;
- define %Result = 14;
- goto Return_FailureMsg;
-
-
- Modem_OK:
- wait until 2;
- ModemStr = %mdm_Init;
- if ModemStr <> "" goto Add_V1;
- ModemStr = %mdm_Prefix;
- Add_V1:
- ModemStr = ModemStr & "V1";
- send ModemStr;
- sendm %mdm_Suffix;
- wait
- %mdm_Ack goto End_Wait1
- until 10;
-
- End_Wait1:
- wait until 2;
-
- 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 450;
- define %Result = 13;
- goto Return_FailureMsg;
-
- Modem_Success:
- wait until 2;
- Result = %Success;
- return;
-
- Modem_Failure:
-
- No_Dial_Tone:
- define %Result = 13;
- goto Return_FailureMsg;
-
- 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:
- on cancel goto Exit_Cancel;
- gosub Hangup;
-
- Exit_Cancel:
- Result = %Cancel;
- define %Result = 12;
- return;
-
- Phone_Failed:
- if FailStr <> "" goto Exit_Failure;
- FailStr = "Dialing failed";
-
- Exit_Failure:
- define %FailureMsg = FailStr;
- define %Result = 13;
- Result = %Failure;
- return;
-
-
- !! NETWORK and LOGON
-
- login:
- if %Connected = 1 goto Dont_Show_Message;
- show "Logging into IntelliCharge processing center";
-
- Dont_Show_Message:
- Tries = 7;
- on cancel goto Return_Cancel;
- FirstTry = %TRUE;
- FailStr = "";
- ETX = "^C";
- CompuServeHost = "CPS^M";
-
- Start_Connect:
- if Tries = 0 goto CIS_Failure;
- Tries = Tries - 1;
-
- Connect_Wait:
- wait
- "UIC:" goto Send_ETX,
- "Host Name:" goto Send_Host_Name,
- "User ID:" goto Send_ID,
- "Password:" goto Send_Password
- until 80;
-
- Send_CR:
- send %CR;
- goto Start_Connect;
-
- Send_ETX:
- send ETX;
- goto Connect_Wait;
-
- Send_Host_Name:
- send CompuServeHost;
- goto Connect_Wait;
-
- Send_ID:
- send %UserID & %LogonParams & "/INT" & %CR;
- goto Connect_Wait;
-
- Send_Password:
- send %Password & %CR;
- goto Logon_Wait;
-
- Logon_Wait:
- wait
- "Address ?" goto Return_Success,
- "CompuServe" goto Return_Success,
- "OK" goto Return_Success,
- "^F" goto Return_Success,
- "? LOG" goto Process_Log_Msg,
- "??LOG" goto Process_Log_Msg,
- " NTW" goto System_Unavailable,
- "^[I" goto Send_Response
- until 200;
- goto CIS_Failure;
-
- Process_Log_Msg:
- wait
- "INE" goto Bad_ID,
- "ISX" goto Bad_ID,
- "SIL" goto System_Unavailable,
- "SIU" goto System_Unavailable,
- "SNA" goto System_Unavailable,
- "STU" goto System_Unavailable
- until 50;
- goto Try_Again;
-
- Bad_ID:
- define %Result = 15;
- goto Return_FailureMsg;
-
- System_Unavailable:
- define %Result = 17;
- goto Return_FailureMsg;
-
- Try_Again:
- if not FirstTry goto CIS_Failure;
- send ETX;
- FirstTry = %FALSE;
- wait
- "User ID" goto Send_ID
- until 140;
- goto CIS_Failure;
-
- Send_Response:
- !! sendi "#IBXQW3,AP,+";
- sendi %ESCIResponse;
- Result = %Success;
- return;
-
- CIS_Failure:
- define %Result = 15;
- goto Return_FailureMsg;
-
- Return_FailureMsg:
- define %FailureMsg = "Disconnecting";
- Result = %Failure;
- return;
-
- Return_Cancel:
- Result = %Cancel;
- return;
-
- Return_Success:
- define %Result = 0;
- Result = %Success;
- return;
-
-