home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / phon22.zip / DISCONCT.19 next >
Text File  |  1994-06-28  |  4KB  |  181 lines

  1. !
  2. !  Copyright (c) 1993
  3. !  by CompuServe Incorporated, Columbus, Ohio
  4. !
  5. !  The information in this software is subject to change without
  6. !  notice and should not be construed as a commitment by CompuServe.
  7. !
  8. !  v1.9 6/28/94 Mike Tannenbaum 75110,2037 Send messages by email only
  9. !
  10. !  DISCONCT:
  11. !  Handles all network/modem disconnections
  12. !  %LOCAL  = 1 if hanging up while network script running
  13. !     = 2 if hanging up before connection
  14. !
  15. !  OldOff = 0;   Follow new fast hangup procedure
  16. !  OldOff = 1;   Use old hangup procedure
  17. !  OldOff = 2;   Use local hangup without sending bye
  18. !
  19. !+V
  20. ! "3.5"
  21. !-V
  22.  
  23. OldOff = 0;
  24. WaitTime = 8;
  25. attempts = 0;
  26.  
  27. CompuServe = 1;
  28. SprintNet = 2;
  29. CSIRnet = 16;
  30. Datex_J = 19;
  31. Internet = 25;
  32. Direct = 40;
  33. Result = %Success;
  34. ifndef %BreakChar = "#";
  35.  
  36. DirectConnect = (%Network = Direct) or (%DialType = 2);
  37.  
  38. ifndef %LOCAL = 0;
  39. if %LOCAL = 1 goto Do_Local_Hangup;
  40. if %LOCAL = 2 goto Send_Hangup;
  41.  
  42. if %Network = Internet goto Exit_Script;
  43. if %Network = CompuServe goto Start_Wait;
  44. if %Network = Direct goto Start_Wait;
  45. if %Network = Datex_J goto Hangup_Datex_J;
  46. if %Network = SprintNet goto Hangup_SprintNet;
  47. if %Network = CSIRnet goto Hangup_CSIRnet;
  48. goto Do_Local_Hangup;
  49.  
  50. Start_Wait:
  51.     wait
  52.         "XPAD:"        goto Hangup_Complete,
  53.         "ITI:"         goto Hangup_Complete,
  54.         "Host Name:"   goto Send_Bye,
  55.         "User ID:"     goto Send_Host,
  56.         "UIC:"         goto Send_UIC,
  57.         %mdm_Failure   goto Got_Nocarr
  58.     until 80;
  59.     goto Do_Local_Hangup;
  60.  
  61. Send_Bye:
  62.     if OldOff = 2 goto Do_Local_Hangup;
  63.     send "BYE^M";
  64.     if DirectConnect goto Hangup_Complete;
  65.     if OldOff = 1 goto Do_Local_Hangup;
  66.     goto Wait_NO_CARRIER;
  67.  
  68. Send_Host:
  69.     send "/HOST^M";
  70.     goto Start_Wait;
  71.  
  72. Send_UIC:
  73.     send "^C";
  74.     wait until 30;
  75.     goto Start_Wait;
  76.  
  77. Hangup_SprintNet:
  78.     show "Disconnecting from SprintNet";
  79.     wait
  80.         "disconnected"  goto Send_Sprint_Hangup
  81.     until 60;
  82.     goto Do_Local_Hangup;
  83.  
  84. Send_Sprint_Hangup:
  85.     wait until 3;
  86.     send "HANGUP^M";
  87.     goto Wait_NO_CARRIER;
  88.  
  89. Hangup_CSIRnet:
  90.     show "Disconnecting from CSIR-Net";
  91.     wait until 40;
  92.     send "Z";
  93.     goto Wait_NO_CARRIER;
  94.  
  95. Hangup_Datex_J:
  96.     show "Disconnecting from Datex-J";
  97.     wait 
  98.         "Host Name:"   goto Send_OFF,  
  99.         "CLR"    goto Clear_PAD
  100.     until 100;
  101.     ! fall through...
  102.  
  103. Clear_PAD:
  104.     wait until 60;
  105.     send "*9#";
  106.     goto Wait_NO_CARRIER;
  107.  
  108. Send_OFF:
  109.     send "OFF" & %CR;
  110.     goto Hangup_Datex_J;
  111.  
  112. Wait_NO_CARRIER:
  113.     show "Wait...";
  114.     if DirectConnect goto Hangup_Complete;
  115.     wait
  116.         "BYE^M"     goto Hangup_Complete,
  117.         %mdm_Failure   goto Got_Nocarr
  118.     until 90;
  119.  
  120.     sendm %mdm_EscapeCode;
  121.  
  122.     wait
  123.         %mdm_Failure    goto Got_Nocarr,
  124.         %mdm_Ack goto Send_Hangup
  125.     until 20;
  126.     ! fall through...
  127.  
  128. Do_Local_Hangup:
  129.     if DirectConnect goto Hangup_Direct;
  130.  
  131.     wait until 2 * WaitTime;
  132.     sendm %mdm_EscapeCode;
  133.  
  134.     wait
  135.         %mdm_Ack  goto End_Escape_Wait,
  136.         %mdm_Failure   goto Got_Nocarr
  137.     until 16;
  138.     goto Send_Hangup;
  139.  
  140. End_Escape_Wait:
  141.     show "Modem Received Escape Code: OK";
  142.     wait until WaitTime;
  143.     ! fall through...
  144.  
  145. Send_Hangup:
  146.     sendm %mdm_Prefix;
  147.     sendm %mdm_Hangup;
  148.     sendm %mdm_Suffix;
  149.     attempts = attempts + 1;
  150.  
  151.     wait
  152.         %mdm_Ack  goto Hangok_Almost,
  153.         %mdm_Failure    goto Got_Nocarr
  154.     until 15;
  155.  
  156.     if attempts = 2 goto Hangup_Complete;
  157.     goto Do_Local_Hangup;
  158.  
  159. Hangok_Almost:
  160.     show "Modem Responds OK to Hangup";
  161.     wait until 10;
  162.     goto Hangup_Complete;
  163.  
  164. Got_Nocarr:
  165.     show "NO CARRIER";
  166.     wait until 10;
  167.     goto Hangup_Complete;
  168.  
  169. Hangup_Direct:
  170.     sendm %BreakChar;
  171.     sendm %BreakChar;
  172.     sendm %BreakChar;
  173.  
  174. Hangup_Complete:
  175.     Result = %Cancel;
  176.     if %LOCAL > 0  goto Exit_Script;
  177.     call %Dir & "last.scr" () : Result;
  178. Exit_Script:
  179.     define %LOCAL = 0;
  180.     exit Result;
  181.