home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / script.doc < prev    next >
Text File  |  1994-11-29  |  28KB  |  938 lines

  1.  
  2.  
  3.  
  4.  
  5. INTRODUCTION
  6. ------------
  7.  
  8. Connect Scripting is the name that CompuServe has given to the scripting
  9. language found in its various proprietary software programs, including
  10. the CompuServe Information Manager.  Connect Scripting is, and does, 
  11. just what the name implies.  It is a scripting language designed to 
  12. allow CIM to navigate through alternate networks to access the 
  13. CompuServe host computers.
  14.  
  15.  
  16. REASON
  17. ------
  18.  
  19. There are numerous networks that CIM needs to support so that CompuServe
  20. members, both domestic and international, can have access to the
  21. CompuServe Information Service.  Some examples of these networks would be
  22. Tymnet, SprintNet, DataPac (Canada), Datex-P (Germany), FALNet
  23. (Australia), Fenics (Japan), and, of course, the CompuServe Network. 
  24. Each network has it's own sequence of commands to route your call through
  25. to CompuServe.
  26.  
  27. In the past, these procedures were programmed into the Information
  28. Manager, which meant that anytime a network changed it's logon procedure,
  29. or a new network was added that allowed access to CompuServe, a new
  30. version of the Information Manager had to be created.  Also, what about
  31. those members who use modem pools or local area networks that required
  32. certain access commands just to get an outside line so that they, in
  33. turn, could call a local access number? Connect scripting was implemented
  34. to allow such accesses and to make updating to available networks easier.
  35.  
  36.  
  37. USAGE
  38. -----
  39.  
  40. Those who have had experience with programming languages will 
  41. find it easy to learn the connect script language for CIM.  For
  42. those members it is a matter of being familiar with the semantics and
  43. syntax and reviewing some examples.  Both are provided with
  44. this document.
  45.  
  46. Others will need to little bit more help.  Since it is impossible to teach
  47. programming techniques with a few short paragraphs of explanations, there
  48. is a better way for those who need that extra help. It would be better to
  49. take a script that already exists and simply modify it to match your
  50. situation.  All of the scripts that are included basically follow the
  51. same pattern:   dial the number, access the network, send the correct
  52. responses to the expected prompts, and then give control over to CIM once
  53. you reach CompuServe.  There is no need to "reinvent the wheel".  Take a
  54. script that already exist and alter it. There are examples included to
  55. help.
  56.  
  57. EXAMPLES
  58. --------
  59.  
  60. When the new script is created, it needs to be included in the list with
  61. the other scripts.  To do this you will need to alter a portion of the
  62. CONNECT.SCR script.  Looking at the example below, there are three places
  63. where alterations are necessary for you script to be included.  
  64.  
  65. Let's say we created a script for the "MakeBelieve" network.  After
  66. creating the script for the MakeBelieve Network we would name the script
  67. file "MAKEBE.SCR" and put it in the CCL folder for the Macintosh version
  68. of CIM or in the same directory where the CIM.EXE file is located for the
  69. DOS version.  The script needs to be included in the list that is in the
  70. beginning of the CONNECT.SCR.  You will find the MakeBelieve script
  71. entered as #9 on the list.  We had to move the scripts that follow it on
  72. the list down one line and renumbers them so that the scripts will show
  73. up alphabetized in the Network popup menu in the session settings:
  74.  
  75. !---------------------------------------------------------------------!
  76. !                                                                         
  77. !
  78. !  Copyright (c) 1991                                                 
  79. !  by CompuServe Incorporated, Columbus, Ohio                        
  80. !                                                                     
  81. !  The information in this software is subject to change without     
  82. !  notice and should not be construed as a commitment by CompuServe.  
  83. !                                                                     
  84. !     Connect Script:                                                 
  85. !                                                                     
  86. !     Handles CompuServe and Direct.                                  
  87. !---------------------------------------------------------------------!
  88.  
  89. !+N
  90. CompuServe = 1;         ! "CompuServe"
  91. Telenet = 2;            ! "Telenet"
  92. Tymnet = 3;             ! "Tymnet"
  93. DataPac = 4;            ! "DataPac"
  94. CSC_Europe = 5;         ! "CSC Europe"
  95. CSC = 6;                ! "CSC"
  96. ConnNet = 7;            ! "ConnNet"
  97. LATA = 8;               ! "LATA"
  98. MakeBelieve = 9;        ! "MakeBelieve"
  99. Telepac = 10;           ! "Telepac"
  100.  
  101.  
  102.  
  103. Then there needs to be an entry in the CONNECT.SCR file like this: (the
  104. new entry is the last line of the following example)
  105.  
  106.     UsingModem = %TRUE;
  107.  
  108.     if %Network = CompuServe goto Connect_CIS;
  109.     if %Network = Telenet goto Connect_Telenet;
  110.     if %Network = Tymnet goto Connect_Tymnet;
  111.     if %Network = DataPac goto Connect_DataPac;
  112.     if %Network = CSC_Europe goto Connect_CSC_Europe;
  113.     if %Network = CSC goto Connect_CSC;
  114.     if %Network = MakeBelieve goto Connect_MakeBelieve;  (this is the new line)
  115.  
  116.  
  117.  
  118. Then, you will need to put a label later in the file so that when you use
  119. the MakeBelieve network the script will be able to find
  120. it.  The label will look like this:
  121.  
  122. !--------------------------!
  123. !  Connect to MakeBelieve  !
  124. !--------------------------!
  125.  
  126. Connect_MakeBelieve:                      
  127.     (This is the label for the new script)
  128.     call %Dir & "makebe.scr" () : Result; 
  129.     (This will cause the script to execute)
  130.     goto Handle_Network_Return;           
  131.     (This is a standard call for all scripts )
  132.  
  133.  
  134. Again, you will want to take a look at the scripts that are included as
  135. examples and use those entries as a guide.
  136.  
  137.  
  138.  
  139. CONNECT SCRIPT DOCUMENTATION
  140.  
  141.  
  142. Semantic Information:
  143.  
  144.  
  145. ASSIGNMENT:  Used to assign a value to a variable or a global symbol.
  146.     The identifier on the left hand side automatically takes on the
  147.     type of the expression on the right hand side.
  148.  
  149.     identifier   = expression;
  150.     
  151.         Example:  
  152.             CompuServe = 1; ! "CompuServe"
  153.  
  154.  
  155. CALL STATEMENT:  Allows a call to an external script file.  The
  156.     expression in the call statement must be a string expression that
  157.     specifies the name of the script file to be called.  Also, note
  158.     that the case is irrelevant concerning the expression (script
  159.     name).
  160.  
  161.     call expression [arguments [return_value]]  ;
  162.  
  163.         Example:  
  164.             call %Dir & "first.scr" () : Result;
  165.  
  166.     Arguments and return values are optional.  Arguments are
  167.     referenced as Arg1, Arg2, Arg3, etc. within the called script.
  168.  
  169.         Example:  
  170.             call %Dir & "phone.scr" (dial) : Result;
  171.             ("(dial)" is Arg1 for "phone.scr")
  172.  
  173.     On return from the call, the return value identifier (if one
  174.     exists) is assigned the exit value from the called script.
  175.  
  176.         Example:  
  177.             ("Result" is the return value identifier in the
  178.         above example)
  179.  
  180.     If the called script is not successfully interpreted, both the
  181.     called script and the calling script fail.
  182.  
  183.  
  184.  
  185. COMMENTS:  Comments begin with the symbol '!' and extend to the end of
  186.     the line.
  187.  
  188.     Example:  
  189.         CompuServe = 1; ! "CompuServe"
  190.  
  191.  
  192.  
  193. CONTROL CHARACTERS:  Within a string, a control character is specified
  194.     by prefixing a character with the '^' (caret) symbol.  For
  195.     example, doing a send of the string "^M" will cause a carriage
  196.     return to be sent.
  197.  
  198.     Example:  
  199.         carriage_return = "^M";
  200.  
  201.  
  202. DEFINE: Used to define global symbols.
  203.  
  204.     Example:  
  205.         define %CR = "^M";
  206.  
  207.  
  208.  
  209. EXPRESSIONS:    
  210.        Logical operators:   and, or, not
  211.     Relational operators:   <  ,  <=  ,  =  ,   <>  ,  >  ,   >=
  212.        String catenation:   &
  213.     Arithmetic operators:   +, -, *, /
  214.          Empty_statement:   ;
  215.        Valid expressions:   expr1 or expr2
  216.                 expr2  and expr3
  217.                 not  expr3              
  218.                 expr4  <=  expr4
  219.                 expr5 & expr6
  220.                 - expr6 + expr7
  221.                 expr7 * expr8
  222.                 ((  expr8 - expr9 ) > expr10 )
  223.  
  224.  
  225.  
  226. EXIT STATEMENT:  Terminates the script and causes a value to be passed
  227.     back to the application or thecalling script (as the return
  228.     value).  The exit expression value must be a non-negative integer
  229.     and is often a global symbol that was defined by the application.
  230.     
  231.     exit expression ;
  232.  
  233.         Example:  
  234.             exit %Success;
  235.  
  236.  
  237.  
  238. GOSUB STATEMENT:  The identifier in the gosub statement must be a
  239.     label.  The address of the statement following the gosub is saved
  240.     and control is transferred to the label specified.  A return
  241.     statement will return control to the saved address.
  242.  
  243.     gosub identifier  ;
  244.  
  245.         Example:  
  246.             gosub Hangup_Connect;
  247.         
  248.  
  249.  
  250. GOTO STATEMENT:  The identifier in the goto statement must be a label.
  251.     Control is transferred to the label specified.
  252.  
  253.     goto identifier  ;
  254.  
  255.         Example:  
  256.             if Result = %Cancel goto Cancel_Connect;
  257.  
  258.  
  259.  
  260. IDENTIFIERS:  Identifiers are labels, variables, and global symbols.
  261.     Labels and variables must begin with a letter and global
  262.     symbols must begin with a percent sign (%).  Identifiers may
  263.     contain  letters, digits, and underscores.  The maximum length of
  264.     an identifier is 31 characters.
  265.  
  266.  
  267.  
  268. IF STATEMENT:  The if expression must be either an integer expression
  269.     or a logical expression.  If the value of the expression is
  270.     non-zero (true) then the associated goto is executed.
  271.  
  272.     if expression  goto identifier  ;
  273.  
  274.         Example:  
  275.             if Result = %Cancel goto Cancel_Connect
  276.  
  277.  
  278.  
  279. IFNDEF STATEMENT:  Used to conditionally assign a value to a global
  280.     symbol.  The assignment takes place only if the symbol is not
  281.     currently defined.
  282.  
  283.     ifndef global_symbol  = expression  ;
  284.  
  285.  
  286.  
  287. INIT STATEMENT:  Initializes the port.  The init expressions must be
  288.     integers (they represent port and baud rate).
  289.  
  290.     init expression  , expression ;
  291.  
  292.         Example:  
  293.             init %Port, %BaudRate;
  294.  
  295.     After this statement is executed, the global symbol %_init
  296.     contains the value returned.
  297.  
  298.  
  299.  
  300. LABELS:  Labels are non-executable statements that allows flow control
  301.     of the script and is used in conjunction with the goto and gosub
  302.     statements.  Labels end with a colon (:).
  303.     
  304.     Example:  
  305.         Do_CIS_Script:
  306.     
  307.     
  308.  
  309. ON-CANCEL STATEMENT:  Used to define a cancel label.  This is the
  310.     default transfer label on cancel during a wait statement.  (Note:
  311.     Do not depend on the stack state after this statement.  It is a
  312.     Goto and does not respect returns, be careful of stack overflow!)
  313.  
  314.     on cancel goto identifier ;
  315.  
  316.         Example:  
  317.             on cancel goto Cancel_Connect;
  318.  
  319.  
  320.  
  321. RESET STATEMENT:  Resets the port.
  322.  
  323.     reset;
  324.  
  325.  
  326.  
  327. RETURN STATEMENT:  Returns control to the address that was saved when
  328.     the associated gosub was called.
  329.  
  330.     return;
  331.  
  332.  
  333.  
  334. SEND STATEMENT:  The send expression may be integer or string.
  335.     Integer expressions are converted to character strings before
  336.     being sent.
  337.  
  338.     send expression ;
  339.  
  340.         Example:  
  341.             send %CR;
  342.  
  343.  
  344.  
  345. SEND-ESCI STATEMENT:  Sends the expression as an ESC I response, along
  346.     with its 'checksum' as computed per CompuServe specifications.
  347.  
  348.       sendi expression ;
  349.  
  350.  
  351.  
  352. SEND-MODEM STATEMENT:  Interprets modem commands within the string as
  353.     the string is sent (~ = pause, # = break, \ = break in WinCIM
  354.     only).  To send a break character to your modem, use a 
  355.     caret (^) before the # symbol.
  356.  
  357.     sendm expression ;
  358.  
  359.         Example:
  360.             sendm "^#";
  361.  
  362.  
  363.  
  364. SHOW STATEMENT:  The show expression may be integer or string. Integer
  365.     expressions are converted to character strings before being shown
  366.     in the dialog.
  367.  
  368.     show "text_string" ; (can also be a variable)
  369.  
  370.         Example:  
  371.             show "Connect cancelled"; -or- show %FailureMsg;
  372.  
  373.  
  374.  
  375. VARIABLES:  There is no need to declare variables (local) before using
  376.     them in an assigment statement.  The type (either integer or
  377.     string) of a variable depends on the type of whatever expression
  378.     is assigned into it.  The type of a variable will change
  379.     dynamically if a different type of expression is later assigned
  380.     into it.  Since a variable does NOT have a default value OR type,
  381.     any variables that appear on the right hand side of an assignment
  382.     must be initialized before being used.  This is VERY important!
  383.  
  384.     LOCAL:
  385.     The scope of a variable is local to the current script file.  If a
  386.     secondary script is called, it cannot access the value of a
  387.     variable from the primary script.  Reusing a variable name in the
  388.     secondary script will cause a new (uninitialized) local copy of
  389.     that variable to be created.  On return to the primary script,
  390.     the original variable (containing the same value that it
  391.     contained prior to the call) is again accessible
  392.  
  393.     GLOBAL SYMBOLS: 
  394.     Global symbols are similar to variables except for their scope. 
  395.     They can be initialized prior to the execution of a script and
  396.     they maintain values across multiple script files.  They provide
  397.     a mechanism for setting up initial values and for passing
  398.     information between script files.  Also, global symbols must
  399.     begin with a percent sign (%) and are defined by using the define
  400.     command.
  401.  
  402.         Example:
  403.             define %CR = "^M";
  404.  
  405.  
  406.  
  407. WAIT STATEMENT:  Tries to match incoming characters against the
  408.     specified strings.  If there is a match the associated goto is
  409.     executed.  The wait statement expression is an integer expression
  410.     that represents tenths of a second (e.g., 50 = 5 seconds).  The
  411.     wait statement continues trying to do a match for the length of
  412.     time specified.
  413.  
  414.         wait wait_item  goto identifier
  415.  
  416.     The else part of the wait statement is used to handle a cancel
  417.     (on-cancel).  If the user cancels before there is a match or a
  418.     timeout then the goto associated with the else will be executed.
  419.     If the wait statement does not have an else part then control
  420.     transfers to the default cancel label specified in the most
  421.     recently executed "on cancel" statement.  If no cancel label is
  422.     specified then control transfers to the statement following the
  423.     wait.
  424.  
  425.         until expression else goto identifier ;
  426.  
  427.  
  428.         Example:  
  429.             wait
  430.                "UIC:"       goto Send_ETX,
  431.                "Host Name:" goto Send_Host_Name,
  432.                "User ID:"   goto Send_ID,
  433.                "Password:"  goto Send_Password
  434.             until 80;
  435.  
  436.     If no match strings are specified, incoming characters and
  437.     user attempts to cancel are ignored.  A wait statement with 
  438.     no match strings is in effect an unconditional pause for 
  439.     the length of time specified.
  440.  
  441.     Note that wait statements provide the only places during
  442.     script execution where user cancels will be processed.
  443.  
  444.  
  445. Sample scripts:
  446.  
  447. !---------------------------------------------------------------------!
  448. !                                                                     !
  449. !  Copyright (c) 1991                                                 !  
  450. !  by CompuServe Incorporated, Columbus, Ohio                         !
  451. !                                                                     !
  452. !  The information in this software is subject to change without      !
  453. !  notice and should not be construed as a commitment by CompuServe.  !
  454. !                                                                     !
  455. !     Connect Script:                                                 !
  456. !                                                                     !
  457. !     Handles CompuServe and Direct.                                  !
  458. !---------------------------------------------------------------------!
  459.  
  460. !+N
  461. CompuServe = 1;         ! "CompuServe"
  462. Telenet = 2;            ! "Telenet"
  463. Tymnet = 3;             ! "Tymnet"
  464. DataPac = 4;            ! "DataPac"
  465. CSC_Europe = 5;         ! "CSC Europe"
  466. CSC = 6;                ! "CSC"
  467. ConnNet = 7;            ! "ConnNet"
  468. LATA = 8;               ! "LATA"
  469. Telepac = 9;            ! "Telepac"
  470. Istel = 10;             ! "Istel"
  471. Datex_P = 11;           ! "Datex-P"
  472. Dialplus = 12;          ! "Dialplus"
  473. NIF = 13;               ! "NIF"
  474. CompuPass = 14;         ! "CompuPass"
  475. FALNET = 15;            ! "FALNET"
  476. Direct = 16;            ! "Direct"
  477. !-N
  478.  
  479. define %CR = "^M";
  480. define %FALSE = 0;
  481. define %TRUE = 1;
  482.  
  483. dial = 0;
  484. hangup = 1;
  485.  
  486.  
  487. !------------------------!
  488. !     Main Program       !
  489. !------------------------!
  490.  
  491.     init %Port, %BaudRate;
  492.     if %_init goto Continue_Connect;
  493.  
  494.     define %FailureMsg = "Could not initialize port";
  495.     goto Connect_Fatal;
  496.  
  497. Continue_Connect:
  498.     UsingModem = %FALSE;
  499.     call %Dir & "first.scr" () : Result;
  500.     if Result = %Cancel goto Cancel_Connect;
  501.     if Result = %Failure goto Connect_Failure;
  502.     if Result = %Fatal goto Connect_Fatal;
  503.  
  504.     on cancel goto Cancel_Connect;
  505.     DirectConnect = (%Network = Direct);
  506.     if DirectConnect goto Connect_CIS;
  507.  
  508.     call %Dir & "phone.scr" (dial) : Result;
  509.  
  510.     if Result = %Cancel goto Cancel_Connect;
  511.     if Result = %Failure goto Connect_Failure;
  512.     if Result = %Fatal goto Connect_Fatal;
  513.  
  514.     UsingModem = %TRUE;
  515.  
  516.     if %Network = CompuServe goto Connect_CIS;
  517.     if %Network = Telenet goto Connect_Telenet;
  518.     if %Network = Tymnet goto Connect_Tymnet;
  519.     if %Network = DataPac goto Connect_DataPac;
  520.     if %Network = CSC_Europe goto Connect_CSC_Europe;
  521.     if %Network = CSC goto Connect_CSC;
  522.     if %Network = ConnNet goto Connect_ConnNet;
  523.     if %Network = LATA goto Connect_LATA;
  524.     if %Network = Telepac goto Connect_Telepac;
  525.     if %Network = Istel goto Connect_Istel;
  526.     if %Network = Datex_P goto Connect_Datex_P;
  527.     if %Network = Dialplus goto Connect_Dialplus;
  528.     if %Network = NIF goto Connect_NIF;
  529.     if %Network = CompuPass goto Connect_CompuPass;
  530.     if %Network = FALNET goto Connect_FALNET;
  531.     define %FailureMsg = "Network not supported";
  532.     goto Connect_Fatal;
  533.  
  534. !----------------------!
  535. !  Connect to Telenet  !
  536. !----------------------!
  537.  
  538. Connect_Telenet:
  539.     call %Dir & "telenet.scr" () : Result;
  540.     goto Handle_Network_Return;
  541.  
  542. !----------------------!
  543. !  Connect to Tymnet   !
  544. !----------------------!
  545.  
  546. Connect_Tymnet:
  547.     call %Dir & "tymnet.scr" () : Result;
  548.     goto Handle_Network_Return;
  549.  
  550. !----------------------!
  551. !  Connect to DataPac  !
  552. !----------------------!
  553.  
  554. Connect_DataPac:
  555.     call %Dir & "datapac.scr" () : Result;
  556.     goto Handle_Network_Return;
  557.  
  558. !-------------------------!
  559. !  Connect to CSC Europe  !
  560. !-------------------------!
  561.  
  562. Connect_CSC_Europe:
  563.     call %Dir & "csc.scr" (%TRUE) : Result;
  564.     goto Handle_Network_Return;
  565.  
  566. !----------------------!
  567. !  Connect to CSC      !
  568. !----------------------!
  569.  
  570. Connect_CSC:
  571.     call %Dir & "csc.scr" (%FALSE) : Result;
  572.     goto Handle_Network_Return;
  573.  
  574.  
  575. !----------------------!
  576. !  Connect to ConnNet  !
  577. !----------------------!
  578.  
  579. Connect_ConnNet:
  580.     call %Dir & "connnet.scr" () : Result;
  581.     goto Handle_Network_Return;
  582.  
  583. !----------------------!
  584. !  Connect to LATA     !
  585. !----------------------!
  586.  
  587. Connect_LATA:
  588.     call %Dir & "lata.scr" () : Result;
  589.     goto Handle_Network_Return;
  590.  
  591. !----------------------!
  592. !  Connect to Telepac  !
  593. !----------------------!
  594.  
  595. Connect_Telepac:
  596.     call %Dir & "telepac.scr" () : Result;
  597.     goto Handle_Network_Return;
  598.  
  599. !----------------------!
  600. !  Connect to Istel    !
  601. !----------------------!
  602.  
  603. Connect_Istel:
  604.     call %Dir & "istel.scr" () : Result;
  605.     goto Handle_Network_Return;
  606.  
  607. !----------------------!
  608. !  Connect to Datex-P  !
  609. !----------------------!
  610.  
  611. Connect_Datex_P:
  612.     call %Dir & "datex.scr" () : Result;
  613.     goto Handle_Network_Return;
  614.  
  615.  
  616. !----------------------!
  617. !  Connect to Dialplus !
  618. !----------------------!
  619.  
  620. Connect_Dialplus:
  621.     call %Dir & "dialplus.scr" () : Result;
  622.     goto Handle_Network_Return;
  623.  
  624. !------------------!
  625. !  Connect to NIF  !
  626. !------------------!
  627.  
  628. Connect_NIF:
  629.     call %Dir & "fenics.scr" (%TRUE) : Result;
  630.     goto Handle_Network_Return;
  631.  
  632. !------------------------!
  633. !  Connect to CompuPass  !
  634. !------------------------!
  635.  
  636. Connect_CompuPass:
  637.     call %Dir & "fenics.scr" (%FALSE) : Result;
  638.     goto Handle_Network_Return;
  639.  
  640. !------------------------!
  641. !  Connect to CompuPass  !
  642. !------------------------!
  643.  
  644. Connect_FALNET:
  645.     call %Dir & "falnet.scr" (%FALSE) : Result;
  646.     goto Handle_Network_Return;
  647.  
  648. !-------------------------!
  649. !  Handle Network Return  !
  650. !-------------------------!
  651.  
  652. Handle_Network_Return:
  653.     if Result = %Success goto Do_CIS_Script;
  654.     if Result = %Cancel goto Cancel_Connect;
  655.     if Result = %Fatal goto Connect_Fatal;
  656.     goto Connect_Failure;
  657.  
  658.  
  659. !-------------------!
  660. !  Connect to CIS   !
  661. !-------------------!
  662.  
  663. Connect_CIS:
  664.     send %CR;
  665.  
  666. Do_CIS_Script:
  667.     call %Dir & "cserve.scr" (DirectConnect) : Result;
  668.     if Result = %Failure goto Connect_Failure;
  669.     if Result = %Cancel goto Cancel_Connect;
  670.     if Result = %Fatal goto Connect_Fatal;
  671.     exit %Success;
  672.  
  673. Connect_Failure:
  674.     gosub Hangup_Connect;
  675.     reset;
  676.     exit %Failure;
  677.  
  678. Connect_Fatal:
  679.     gosub Hangup_Connect;
  680.     reset;
  681.     exit %Fatal;
  682.  
  683. Hangup_Connect:
  684.     if not UsingModem goto Hangup_Done;
  685.     call %Dir & "phone.scr" (hangup);
  686.  
  687. Hangup_Done:
  688.     return;
  689.  
  690. Cancel_Connect:
  691.     show "Connect cancelled";
  692.     reset;
  693.     exit %Cancel;
  694.  
  695.  
  696. !---------------------------------------------------------------------!
  697. !                                                                     !
  698. !  Copyright (c) 1991                                                 !  
  699. !  by CompuServe Incorporated, Columbus, Ohio                         !
  700. !                                                                     !
  701. !  The information in this software is subject to change without      !
  702. !  notice and should not be construed as a commitment by CompuServe.  !
  703. !                                                                     !
  704. !  CSERVE Script:                                                     !
  705. !     Connect to CIS.                                                 !
  706. !     First argument is %TRUE if direct connect and %FALSE otherwise  !
  707. !     Success:  returns %Success                                      !
  708. !     Failure:  saves error msg in %FailureMsg and returns %Failure   !
  709. !               or %Fatal (depending on severity).                    !
  710. !---------------------------------------------------------------------!
  711.  
  712.     DirectConnect = Arg1;
  713.     show "Connecting to CompuServe Network";
  714.     Tries = 7;
  715.     on cancel goto Return_Cancel;
  716.     FirstTry = %TRUE;
  717.     FailStr = "";
  718.     ETX = "^C";
  719.     CompuServeHost = "CPS^M";
  720.  
  721. Start_Connect:
  722.     if Tries = 0 goto CIS_Failure;
  723.     Tries = Tries - 1;
  724.  
  725. Connect_Wait:
  726.     wait
  727.     "UIC:"       goto Send_ETX,
  728.     "Host Name:" goto Send_Host_Name,
  729.     "User ID:"   goto Send_ID,
  730.     "Password:"  goto Send_Password
  731.     until 80;
  732.  
  733.     if not DirectConnect goto Send_CR;
  734.     sendm "###";
  735.  
  736. Send_CR:
  737.     send %CR;
  738.     goto Start_Connect;
  739.  
  740. Send_ETX:
  741.     send ETX;
  742.     goto Connect_Wait;
  743.  
  744. Send_Host_Name:
  745.     send CompuServeHost;
  746.     goto Connect_Wait;
  747.  
  748. Send_ID:
  749.     show "Logging onto CompuServe";
  750.     send %UserID & %LogonParams & "/INT\" & %Password & %CR;
  751.     goto Logon_Wait;
  752.  
  753. Send_Password:
  754.     send %Password;
  755.  
  756. Logon_Wait:
  757.     wait
  758.     "CompuServe" goto Return_Success,
  759.     "^F"         goto Return_Success,
  760.     "? LOG"      goto Process_Log_Msg,
  761.     "??LOG"      goto Process_Log_Msg,
  762.     " NTW"       goto Logon_Failure,
  763.     "^["         goto Send_Response
  764.     until 200;
  765.  
  766.     goto CIS_Failure;
  767.  
  768. Process_Log_Msg:
  769.     wait
  770.     "INE"   goto Bad_ID,
  771.     "ISX"   goto Bad_ID_Syntax,
  772.     "SIL"   goto System_Unavailable,
  773.     "SIU"   goto System_Unavailable,
  774.     "SNA"   goto System_Unavailable,
  775.     "STU"   goto System_Unavailable
  776.     until 50;
  777.  
  778.     goto Try_Again;
  779.  
  780. Bad_ID:
  781.     FailStr = "Incorrect user ID or password";
  782.     goto Try_Again;
  783.  
  784. Bad_ID_Syntax:
  785.     FailStr = "Incorrect user ID syntax";
  786.     goto Try_Again;
  787.  
  788. System_Unavailable:
  789.     define %FailureMsg = "The system is unavailable, try again later";
  790.     exit %Fatal;
  791.  
  792. Try_Again:
  793.     if not FirstTry goto CIS_Fatal;
  794.  
  795.     send ETX;
  796.     FirstTry = %FALSE;
  797.  
  798.     wait
  799.     "User ID"       goto Send_ID
  800.     until 140;
  801.  
  802.     goto CIS_Fatal;
  803.  
  804. Logon_Failure:
  805.     define %FailureMsg = "Remote is busy or unavailable";
  806.     exit %Fatal;
  807.  
  808. Send_Response:
  809.     sendi %ESCIResponse;
  810.     exit %Success;
  811.  
  812. CIS_Failure:
  813.     if FailStr <> "" goto Return_Fail_Msg;
  814.     define %FailureMsg = "Unable to connect to CompuServe host";
  815.     exit %Failure;
  816.  
  817. CIS_Fatal:
  818.     if FailStr <> "" goto Return_Fatal_Msg;
  819.     define %FailureMsg = "Unable to connect to CompuServe host";
  820.     exit %Fatal;
  821.  
  822. Return_Fail_Msg:
  823.     define %FailureMsg = FailStr;
  824.     exit %Failure;
  825.     
  826.  
  827. Return_Fatal_Msg:
  828.     define %FailureMsg = FailStr;
  829.     exit %Fatal;
  830.     
  831. Return_Success:
  832.     exit %Success;
  833.  
  834. Return_Cancel:
  835.     exit %Cancel;
  836.  
  837.  
  838.  
  839.  
  840. Global variables:
  841.  
  842.     [{]     %Cancel -The user has cancelled the current operation
  843.         -alternate(secondary connection) will not be attempted.
  844.  
  845.         %ESCIResponse - the response to an ESC-I sequence that was
  846.         received during connection.
  847.  
  848.     [{]     %Failure - A failure has occured - alternate can be
  849.         attempted.
  850.  
  851.     [{]     %Fatal - A fatal error has occured - alternate will not be
  852.         attempted.
  853.  
  854.     [{]     %Success - connection was successful.
  855.  
  856.         %_init - contains the success flag returned after the
  857.         completion of the INIT call.
  858.  
  859.     [{]The above indicated globals are return values .  One of
  860.        these globals must be returned to indicate the success or
  861.        failure of the called script.
  862.  
  863.  
  864. The following globals are set to the information that has been entered in
  865. the Session Settings:
  866.  
  867.         %UserID - set to the User ID.
  868.  
  869.         %Password - set to the password.
  870.  
  871.         %Phone - set to the phone number in the primary connect
  872.         section.
  873.  
  874.         %NetWork - set to the network indicated in the primary
  875.         connect section.
  876.  
  877.         %BaudRate - set to the baud rate as indicated in the
  878.         Primary Connection section.
  879.  
  880.         %Retry - set to the number entered in the Retries field of
  881.         the primary connect section.
  882.     
  883.         %DialType - set to the dial type. (1=Tone, 2=Pulse,
  884.         3=Manual)
  885.  
  886.         %Port - set to the current commport. (For the Macintosh
  887.         version: 1=Modem port, 2=Printer port)
  888.  
  889.         %Dir - set to the pathname for the Data Files Directory
  890.         (DOS).  This is not used for the Macintosh version.
  891.  
  892. The following globals are set to the information that has been entered in
  893. the Modem Control Strings (under Session Settings):
  894.  
  895.         %mdm_Init - set to the contents of the Initialize: field.
  896.  
  897.         %mdm_Prefix - set to the contents of the Prefix: field.
  898.  
  899.     [{]     %mdm_Reset - set to the contents of the Reset: field.
  900.  
  901.     [{]     %mdm_Tone_Dial - set to the contents of the Dial Tone:
  902.         field.
  903.  
  904.     [{]     %mdm_Pulse_Dial - set to the contents of the Dial Pulse:
  905.         field.
  906.  
  907.     [{]     %mdm_Hangup - set to the contents of the Hang Up: field.
  908.  
  909.         %mdm_Suffix - set to the contents of the Suffix: field.
  910.  
  911.         %mdm_EscapeCode - set to the contents of the Escape:
  912.         field.
  913.  
  914.         %mdm_Success - set to the contents of the Connect: field.
  915.  
  916.         %mdm_Ack - set to the contents of the Acknowledge: field.
  917.  
  918.         %mdm_Speaker - set to the state of the Speaker Off
  919.         selection (speaker is on by default).
  920.  
  921.         %LogonParams - set to the entries found in the Logon
  922.         Params field in the Modem section.
  923.  
  924.         %mdm_ECOn - set to the contents of the Error Correction
  925.         field.
  926.  
  927.         %mdm_DCOn - set to the contents of the Data Compression
  928.         field.
  929.  
  930.         %X121Address - set to the X121 call address if using
  931.         Eicon X.25 software.
  932.  
  933.     [{] The above globals will  automatically have the %mdm_Prefix as
  934.         a prefix and %mdm_Suffix as a suffix.
  935.  
  936.  
  937.  
  938.