home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: OtherApp / OtherApp.zip / rhinodem.zip / rcdemo.dat / compuser.rrx < prev    next >
Text File  |  1995-09-29  |  3KB  |  159 lines

  1. /*
  2.  * sample RhinoCom script that connects to CompuServe
  3.  */
  4.  
  5.  
  6. /*
  7.  * Load all the system functions
  8.  *  ( we will use SysSleep )
  9.  */
  10.  
  11. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  12. call SysLoadFuncs
  13.  
  14. /*
  15.  *  create convenient symbols for carriage return,
  16.  *  newline and control-C
  17.  */
  18.  
  19. CR = '0d'x
  20. NL = '0a'x
  21. ctrlc = '03'x
  22.  
  23. /*
  24.  *  Check the phone number field of the RhinoCom Notebook.
  25.  *  If the number has not been filled in, ask the user for one,
  26.  *  and place it in the field.
  27.  */
  28.  
  29. RQUERY 'phone-number'
  30. phone = rc
  31. if phone = '' then do
  32.   ENTRYFIELD '"Enter Phone Number" "Dialing CompuServe"'
  33.   phone = rc
  34.   if phone = '' then signal error1
  35.   rset 'phone-number' phone
  36. end
  37.  
  38. /*
  39.  *  Do the same thing for the Username field.  This is a
  40.  *  little different because Username is a named macro.
  41.  *  Notice that we add a CR to the users response.
  42.  */
  43.  
  44. RQUERY '@username'
  45. username = rc
  46. if username = '' then do
  47.   ENTRYFIELD '"Enter Compuserve User ID" "Dialing CompuServe"'
  48.   username = rc
  49.   if username = '' then signal error1
  50.   NMDefine "named M'username'"username
  51. end
  52.  
  53. /*
  54.  *  And again for the password.  Notice that the entryfield for
  55.  *  this one echoes *'s instead of the characters typed.
  56.  */
  57.  
  58. RQUERY 'password'
  59. password = rc
  60. if password = '' then do
  61.   ENTRYFIELD 'UNREADABLE "Enter Password" "Dialing CompuServe"'
  62.   password = rc
  63.   if password = '' then signal error1
  64.   rset 'password' password
  65. end
  66.  
  67. /*
  68.  *  set up a response string that will execute the named macro "username"
  69.  *  when it sees the "User ID:" prompt from CompuServe
  70.  */
  71.  
  72. RESPONSE 1 MATCH '/User ID:/ /EXEC username/'
  73.  
  74. /*
  75.  *  set up a response string that will send the password
  76.  *  when it sees the prompt from CompuServe
  77.  */
  78.  
  79. RESPONSE 2 MATCH '/Password:/ /EXEC password/'
  80.  
  81. /*
  82.  *  In the rare case that we get the "Host Name" prompt,
  83.  *  we want to reply "CIS"
  84.  */
  85.  
  86. RESPONSE 3 MATCH '/Host Name:/ /WRITE CIS'CR'/'
  87.  
  88. /*
  89.  *  Now that the response strings are ready and waiting, we will
  90.  *  start a dial.  Because the Dial is started in another thread,
  91.  *  we cannot be sure how far along it is when the script resumes.
  92.  */
  93.  
  94. DIAL
  95. call SysSleep 1
  96. rsay CR||NL||'Now Dialing Compuserve . . .'||CR||NL||CR||NL
  97.  
  98. /*
  99.  *  CompuServe does not give an obvious signal when it is connected,
  100.  *  so we will wait for the modem to signal "Connected", then send
  101.  *  a Control-C to wake up CompuServe.
  102.  */
  103.  
  104. RQUERY "@Connect"
  105. connect_string = rc
  106.  
  107. TIMEOUT 45
  108. WAITFOR connect_string
  109. if rc \= 0 then signal error2
  110.  
  111. call SysSleep 1
  112.  
  113. /*
  114.  * SEND ctrl C, this will trigger the pre-defined response strings
  115.  */
  116.  
  117. SEND ctrlc
  118.  
  119. TIMEOUT 30
  120. WAITFOR ' choice '
  121. if rc \= 0 then signal error2
  122.  
  123. RESPONSE 1 CANCEL
  124. RESPONSE 2 CANCEL
  125. RESPONSE 3 CANCEL
  126.  
  127. /*
  128.  *  Go to the Rhintek forum.  When we get there it will prompt "Press <CR> !"
  129.  *  We want the script to supply the response to this prompt.
  130.  */
  131.  
  132. RESPONSE 4 '/<CR>/ /'CR'/'
  133. SEND 'GO Rhintek'||CR
  134. WAITFOR ' choice '
  135. RESPONSE 4 CANCEL
  136.  
  137. exit
  138.  
  139. /*
  140.  *  signal error - user aborted from an Entryfield
  141.  */
  142.  
  143. error1:
  144. rsay 'Compuserve Dial aborted'
  145. exit
  146.  
  147. /*
  148.  *  signal error - failed to get an expected prompt
  149.  *  we want to be sure to clean up the response strings
  150.  */
  151.  
  152. error2:
  153. rsay 'Compuserve Connection failed.'
  154. RESPONSE 1 CANCEL
  155. RESPONSE 2 CANCEL
  156. RESPONSE 3 CANCEL
  157. exit
  158.  
  159.