home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1996 January / SOFM_Jan1996.bin / pc / os2 / zoc / install.fil / SCRIPT / RXSAMPLE / MISC / 7_CALBBS < prev   
Encoding:
Text File  |  1995-09-08  |  4.9 KB  |  201 lines

  1.  
  2.     #  THIS IS AN OLD STYLE ZOC SCRIPT, NOT REXX!!
  3.  
  4.     #  This is a non-functional skeleton for creating an autologin 
  5.     #  script. However you might not need it, since simple autologins 
  6.     #  can be achieved without script programming using the autologin 
  7.     #  feature of the phone book.
  8.  
  9.     #  Scenario:
  10.     #    Let's assume Zaphod Beeblebrox uses the Megadodo bbs on Ursa 
  11.     #    Minor Beta to download new messages and upload the replys that 
  12.     #      he wrote offline. 
  13.     #    This script calls the bbs and eventually tries again until it
  14.     #    gets a CONNECT. Then it goes to the main menu where it downloads
  15.     #    a new mail packet and, if available, uploads Zaphod's replys.
  16.  
  17.  
  18.  
  19.     #  Prevent users from accidently dialling long distance to Ursa Minor Beta
  20.     request "Are you sure you want to make a call across the universe?" "No" "No"
  21.     goto finish
  22.  
  23.  
  24.     #  To test your own script, change the next line to 'debug 1'
  25.     debug 0
  26.  
  27.  
  28.     #  Set a few values (999 is the prefix for inter galactical calls :-)
  29.     setn  waittime 10            ;# time between dials
  30.     setn  maxtry   42            ;# max number of trys
  31.     seta  phone    "999-9283748742893478" ;# phone number to call
  32.     seta  bbs      "Megadodo BBS"         ;# bbs name to log in calling.log
  33.  
  34.  
  35.     #  Init the modem (and fail if no OK received within 5 seconds)
  36.     timeout 5
  37.     send "ATZ"
  38.     wait "OK"
  39.     ifbrk goto fail    
  40.  
  41.     #   Reset counter, clear screen
  42.     setn counter 1
  43.     cls
  44.  
  45.  
  46.     #   MAIN LOOP
  47.     #
  48.  
  49. :loop0
  50.     #  Dial and see what happens
  51.     #  (if the number contains a ^I (TAB) the following text is used
  52.     #  in the CALLING.LOG instead of logging just the phone number)
  53.     dial "%phone%^I%bbs%"
  54.  
  55.     #  Set timeout to 90sec. and wait for a line of text to come
  56.     timeout 90
  57. :loop1
  58.     waitline
  59.  
  60.     #  if something arrived save incoming line to variable 
  61.     #  (lastline might change duringprocessing)
  62.     ifnbrk seta last "%lastline%"
  63.  
  64.     #  else
  65.     #  if WAITLINE timed out, set our variable to TIMEOUT
  66.     ifbrk  seta last "TIMEOUT"
  67.  
  68.     #  Set text compare to non exact matching (that is CONNECT=CONNECT 1200)
  69.     exact    0
  70.  
  71.     #  compare to for CONNECT or CARRIER and if equal, log in
  72.     compa    "%last%" WITH CONNECT
  73.     ifequ    goto login    
  74.  
  75.     compa    "%last%" WITH CARRIER
  76.     ifequ    goto login    
  77.  
  78.  
  79.     #  Try again for BUSY, NO CARRIER
  80.     compa    "%last%" WITH BUSY
  81.     ifequ    goto SomeMore    
  82.  
  83.     compa    "%last%" WITH "NO CARRIER"
  84.     ifequ    goto SomeMore    
  85.  
  86.  
  87.     #  for TIMEOUT hang up
  88.     compa    "%last%" WITH "NO CARRIER"
  89.     ifequ    hangup
  90.  
  91.  
  92.     #   Ignore anything else (Zyxels say 'RINGING' or V42 say 'PROCOL xxx')
  93.     #  and wait for something we know
  94.     goto loop1
  95.  
  96.     #  Increment counter and eventually try again
  97.     #
  98. :SomeMore
  99.     #  ... wait and see if we ...
  100.     delay    %waittime%
  101.  
  102.     #  ... want to try again?
  103.     inc     counter
  104.     compn    %counter% with %maxtry%
  105.     iflow    goto loop0
  106.     ifequ    goto loop0
  107.  
  108.     #   No success after %maxtry% tries
  109.     goto    fail
  110.  
  111.  
  112.  
  113.     ##################
  114.     #  LOGIN        #
  115.     ##################
  116.  
  117. :login
  118.     #  Make a bit noise
  119.     beep 3
  120.     writeln "^M^J^J^MConnection established!!"
  121.     timeout 30
  122.  
  123.     #  log in
  124.     wait  "Name"
  125.     send  "Zaphod Beeblebroox^m"
  126.     wait  "Password"
  127.     send  "heart of gold^m"
  128.  
  129.  
  130.     #  care for the stuff they use to make script programming 
  131.     #  a bit harder (respond will be active whenever
  132.     #  the script processes a DELAY, WAIT or WAITLINE)
  133.     respond "your birth date" "11/11/11^m"
  134.     respond "press <enter> to continue" "^m"
  135.  
  136.     #  Wait for the main menu, go to the mail area and
  137.     #  request to download a mail packet
  138.     timeout 60
  139.     wait "your choice"
  140.     send "m^M"
  141.  
  142.     wait "your choice"
  143.     send "d^M"
  144.  
  145.     wait "file transfer protocol"
  146.     send "z^M"
  147.  
  148.     wait "are you sure"
  149.     send "y^M"
  150.  
  151.  
  152.     #  We could use the download command, but it's easier just to 
  153.     #  let autodownload jump in during a WAIT. So wait for the
  154.     #  'download finished' message and let autodownload care for
  155.     #  the rest 
  156.     
  157.     timeout 600          ;#   download could take a long time
  158.     wait "finished"
  159.  
  160.     wait "your choice"
  161.  
  162.  
  163.     #  Do the same for upload. To find out if an reply file exists
  164.     #  try to open it for reading.
  165.     openfile "hitchh.rep" "r"
  166.     compa "%lastline%" with "##OK##"
  167.     ifnequ goto logout
  168.     closefile 
  169.  
  170.     send "u^M"
  171.  
  172.     wait "file transfer protocol"
  173.     send "z^M"
  174.  
  175.     wait "are you sure"
  176.     send "y^M"
  177.  
  178.     timeout 600          ;#   upload could take a long time
  179.     wait "finished"
  180.  
  181.     #  after up/download go to the main menu and log out
  182. :logout
  183.        #  main menu (send ESC)
  184.     send "^["
  185.  
  186.        #  log out 
  187.     wait "your choice"
  188.     send "L"
  189.  
  190.  
  191.     ##################
  192.     #  THE END       #
  193.     ##################
  194. :finish
  195.     exit
  196.  
  197. :fail
  198.     writeln "ERROR"
  199.     exit
  200.  
  201.