home *** CD-ROM | disk | FTP | other *** search
/ PC Direkt 1995 #3 / PCD_395.iso / kommunik / wincim_d / disk1 / scripts.lib / PHONE.SCR < prev    next >
Encoding:
Text File  |  1994-04-14  |  4.8 KB  |  246 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. !  PHONE:
  9. !    Contains modem/phone related logic.
  10. !    Success:  returns %Success
  11. !    Failure:  saves error msg in %FailureMsg and returns %Failure
  12. !
  13. !+V
  14. ! "3.4.1"
  15. !-V
  16.  
  17. MdmCmd = "";
  18.  
  19. WaitTime = 10;
  20. ifndef %mdm_UserID = "";
  21. ifndef %mdm_Password = "";
  22. ifndef %mdm_ECOn = "";
  23. ifndef %mdm_DCOn = "";
  24.  
  25. if %DialType = 2 goto Direct_Connect;
  26.  
  27. goto Do_Phone_Connect;
  28.  
  29. !
  30. ! Subroutines
  31. !
  32. Hangup_Before_Connect:
  33.     define %LOCAL = 2;
  34.     call %Dir & "disconct.scr" () : Result;
  35.     return;
  36.  
  37. Two_Tries_Hangup:
  38.     gosub Hangup_Before_Connect;
  39.     goto Send_Reset_String;
  40.  
  41.  
  42. !
  43. ! Main Program:  Start_Connect
  44. !
  45. Do_Phone_Connect:
  46.     RingLimit = 5;
  47.     RingCount = 0;
  48.     UsingModem = %FALSE;
  49.     on cancel goto Phone_Cancelled;
  50.  
  51.     if %DialType = 0 goto Get_Tone_Str;
  52.     DialTypeStr = %mdm_Pulse_Dial;        ! Type = DT_Pulse
  53.     goto Init_Modem;
  54.  
  55. Get_Tone_Str:
  56.     DialTypeStr = %mdm_Tone_Dial;        ! Type = DT_Tone
  57.  
  58. Init_Modem:
  59.     show "Modem wird initialisiert";
  60.     MsgStr = %Phone & " wird gewΣhlt";
  61.     tries = 0;
  62.  
  63. Send_Reset_String:
  64.     if (%mdm_Reset = "") goto Modem_OK;
  65.     sendm %mdm_Prefix;
  66.     sendm %mdm_Reset;
  67.     sendm %mdm_Suffix;
  68.  
  69. Send_Wait:
  70.     wait
  71.         "User Id"    goto Send_User_ID,
  72.         "Password"    goto Send_Password,
  73.         %mdm_Ack    goto Modem_OK,
  74.         "0"        goto Modem_OK
  75.     until 40;
  76.  
  77.     tries = tries + 1;
  78.     if tries = 2 goto Two_Tries_Hangup;    ! Two failures to send Reset -
  79.                         ! hang up and try twice more.
  80.     if tries < 4 goto Send_Reset_String;
  81.  
  82.     wait until WaitTime;
  83.  
  84.     FailStr = "Modem antwortet nicht";
  85.     goto Phone_Failed;
  86.  
  87. Send_User_ID:
  88.     !
  89.     ! For those modems that support password security...
  90.     !
  91.     send %mdm_UserID & "^M";
  92.     goto Send_Wait;
  93.  
  94. Send_Password:
  95.     !
  96.     ! For those modems that support password security...
  97.     !
  98.     send %mdm_Password & "^M";
  99.     wait
  100.         "User id"    goto Modem_Security_Error,
  101.         %mdm_Ack    goto Send_Reset_String,
  102.         "0"        goto Send_Reset_String
  103.     until 100;
  104.     goto Send_Reset_String;
  105.  
  106. Modem_Security_Error:
  107.     define %FailureMsg = "Modemsicherheits-Passwort oder User-ID ungⁿltig";
  108.     exit %Fatal;
  109.  
  110. Modem_OK:
  111.     wait until 10;
  112.     if (%mdm_Init = "") goto Check_Modem_Speaker;
  113.     sendm %mdm_Init;
  114.  
  115.     wait
  116.         %mdm_Ack    goto Check_Modem_Speaker,
  117.         "ERROR"        goto Show_Init_Error
  118.     until 33;
  119.     FailStr = "Modem antwortet nicht";
  120.     goto Phone_Failed;
  121.  
  122. Show_Init_Error:
  123.     show "Fehler im Modem-Befehl";
  124.     wait until 10;
  125.  
  126. Check_Modem_Speaker:
  127.     if (%mdm_Speaker <> 0) goto Check_DC;
  128.     MdmCmd = "M0";
  129.  
  130. Check_DC:
  131.     if %mdm_DCOn = "" goto Check_EC;
  132.     MdmCmd = MdmCmd & %mdm_DCOn;
  133.     goto Wait_Ack;
  134.  
  135. Check_EC:
  136.     if %mdm_ECOn = "" goto Wait_Ack;
  137.     MdmCmd = MdmCmd & %mdm_ECOn;
  138.  
  139. Wait_Ack:
  140.     if MdmCmd = "" goto Try_Phone;
  141.     sendm %mdm_Prefix & MdmCmd & %mdm_Suffix;
  142.     wait
  143.         %mdm_Ack    goto Try_Phone,
  144.         "ERROR"        goto Show_Proto_Error
  145.     until 33;
  146.     goto Try_Phone;
  147.  
  148. Show_Proto_Error:
  149.     show "Fehler im Modem-Befehl";
  150.  
  151. Try_Phone:
  152.     wait until 10;
  153.     count = 0;
  154.     FailStr = "";
  155. Dial_Phone:
  156.     if (count > %Retry) goto Phone_Failed;
  157.  
  158.     show MsgStr;
  159.     
  160.     sendm %mdm_Prefix;
  161.     sendm DialTypeStr & %Phone;
  162.     sendm %mdm_Suffix;
  163.  
  164. Start_Phone_Loop:
  165.     wait
  166.         %mdm_Success    goto Modem_Success,
  167.         %mdm_Failure    goto Modem_Failure,
  168.         "No Dial"    goto No_Dial_Tone,
  169.         "Dial Complete"    goto Dial_Complete,
  170.         "Busy"        goto Line_Busy,
  171.         "Ring"        goto Remote_Ring
  172.     until 556;
  173.  
  174.     FailStr = "Fehler beim WΣhlen";
  175.     goto Exit_Failure;
  176.  
  177. Modem_Success:
  178.     wait until 5;
  179. Direct_Connect:
  180.     exit %Success;
  181.  
  182. Modem_Failure:
  183.     FailStr = "Versuch erfolglos, Zugangsnummer prⁿfen";
  184.     wait until WaitTime;
  185.     goto End_Phone_Loop;
  186.  
  187. No_Dial_Tone:
  188.     FailStr = "Kein Freizeichen";
  189.     goto Exit_Failure;
  190.  
  191. Dial_Complete:
  192.     MsgStr = %Phone & " gewΣhlt, warte auf Antwort";
  193.     show MsgStr;
  194.     goto Start_Phone_Loop;
  195.  
  196. Line_Busy:
  197.     FailStr = "Nummer ist besetzt";
  198.     wait until 2 * WaitTime;
  199.     send %CR;
  200.  
  201.     wait
  202.         %mdm_Success    goto End_Line_Busy,
  203.         %mdm_Failure    goto End_Line_Busy,
  204.         "No Dial"    goto End_Line_Busy,
  205.         "Dial Complete"    goto End_Line_Busy,
  206.         "Busy"        goto End_Line_Busy,
  207.         "Ring"        goto End_Line_Busy
  208.     until 56;
  209.  
  210. End_Line_Busy:
  211.     wait until WaitTime;
  212.     goto End_Phone_Loop;
  213.  
  214. Remote_Ring:
  215.     RingCount = RingCount + 1;
  216.     if RingCount <= RingLimit goto Show_Ringing;
  217.  
  218.     FailStr = "Keine Antwort";
  219.     goto End_Phone_Loop;
  220.  
  221. Show_Ringing:
  222.     MsgStr = %Phone & " gewΣhlt, warte auf Antwort";
  223.     show MsgStr;
  224.     goto Start_Phone_Loop;
  225.  
  226. End_Phone_Loop:
  227.     MsgStr = FailStr & ". " & %Phone & " wird gewΣhlt";
  228.     count = count + 1;
  229.     goto Dial_Phone;
  230.  
  231. Phone_Cancelled:
  232.     gosub Hangup_Before_Connect;
  233.     exit Result;
  234.  
  235. Phone_Failed:
  236.     if FailStr <> "" goto Exit_Fatal;
  237.     FailStr = "Fehler beim WΣhlen";
  238.  
  239. Exit_Fatal:
  240.     define %FailureMsg = FailStr;
  241.     exit %Fatal;
  242.  
  243. Exit_Failure:
  244.     define %FailureMsg = FailStr;
  245.     exit %Failure;
  246.