home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / com / zoc / script / xdial < prev   
Text File  |  1994-02-17  |  4KB  |  191 lines

  1.     #    The XDIAL function of ZOC is implemented as a script. 
  2.     #    The Number and BBS-name is given in lastline and are
  3.     #    fetched from there. 
  4.     #    You may modify this script for your own needs.
  5.  
  6.     #    Before you modify this script to call a singe bbs, 
  7.     #    check if the 'Autologin' feature of the phone book 
  8.     #    does not solve your problem already. For a script
  9.     #    calling a single bbs check the SAMPLES directory
  10.     #    (SAMPLES\7_CALBBS)
  11.  
  12.     #    Let's go ...
  13.  
  14.     #   Fetch parameters and number
  15.     #
  16.     seta parmline "%lastline%"    ;# test
  17.     seta number "%parmline%"  |TEL= ; rtrim number
  18.     seta bbs    "%parmline%"  |BOX= ; rtrim bbs
  19.     seta log    "%parmline%"  |LOG= ; rtrim log
  20.     seta init     "%parmline%" |INIT=; rtrim init
  21.     seta waitstr "%parmline%" |WAIT=
  22.  
  23.     exact    1
  24.  
  25.     #    Fetch INIT=xx from the phonebook and eventually send it
  26.     compa    "%init%" WITH ""
  27.     ifnequ    send "%init%"
  28.     ifnequ    wait "OK"
  29.     ifequ     send "^M"
  30.     delay
  31.  
  32.     #    Fetch WAIT=xx from the phonebook or set default value
  33.     compn    "%waitstr%" WITH ""
  34.     ifequ    setn waittime 30 
  35.     ifnequ    setn waittime %waitstr%
  36.  
  37.  
  38.     #   Reset counter
  39.     setn counter 1
  40.     seta msg ""
  41.     cls
  42.     delay
  43.  
  44.  
  45.     #   MAIN LOOP
  46.     #
  47.  
  48. :loop0
  49.     #   wait for something for 90 sec. max
  50.     timeout 90
  51.  
  52.     #    Show status
  53.     seta    status "Call"
  54.     seta    last ""
  55.     call    SayStatus
  56.  
  57.     #    Dial and see what happens
  58.     dial "%number%^i%bbs%"
  59.  
  60. :loop1
  61.     waitline
  62.     ifnbrk seta last "%lastline%"
  63.     ifbrk  seta last "TIMEOUT"
  64.     write  "                           "
  65.     call    SayStatus
  66.  
  67.     exact    1
  68.     compa    "%last%" WITH ""
  69.     ifequ    goto loop1    
  70.  
  71.     exact    0
  72.  
  73.     #    Login for CONNECT, CARRIER or PROTOCOL: LAP-M
  74.     compa    "%last%" WITH CONNECT
  75.     ifequ    goto login    
  76.  
  77.     compa    "%last%" WITH CARRIER
  78.     ifequ    goto login    
  79.  
  80.     compa   "%last%" WITH "PROTOCOL: LAP-M"
  81.     ifequ   goto login      
  82.  
  83.  
  84.     #    Try next time for BUSY, NO CARRIER
  85.     compa    "%last%" WITH BUSY
  86.     ifequ    goto SomeMore    
  87.  
  88.     compa    "%last%" WITH "NO CARRIER"
  89.     ifequ    goto SomeMore    
  90.  
  91.  
  92.     #     Ignore Zyxels saying 'RINGING'
  93.     compa    "%last%" WITH RINGING
  94.     ifequ    goto loop1    
  95.  
  96.  
  97.     #   For anything else hangup ...
  98.     seta    status "Hangup"
  99.     call    SayStatus
  100.     hangup
  101.  
  102. :SomeMore
  103.     #    ... wait and see if we ...
  104.     seta    status "Wait %waittime% Sec."
  105.     call    SayStatus
  106.     delay     %waittime%
  107.  
  108.     #    ... want to try again?
  109.     inc     counter
  110.     compn    %counter% %with% 99
  111.     iflow    goto loop0
  112.     ifequ    goto loop0
  113.  
  114.     #   No success after 99 tries
  115.     seta    status "No success"
  116.     call    SayStatus
  117.     writeln "^J^J^M"
  118.     goto    finish
  119.  
  120.  
  121.  
  122.     ##################
  123.     #    LOGIN        #
  124.     ##################
  125.  
  126. :login
  127.     beep 3
  128.     writeln "^M^J^J^MConnection established!!"
  129.  
  130.  
  131.     #     Fetch and exec startcmd from phonebook
  132.     seta  cmd "%parmline%" |CMD=
  133.     %cmd%
  134.  
  135.     #    Init Wn/Sn loop
  136.     setn n 1
  137.  
  138.     exact 1
  139.  
  140.     #    Send S0 unconditionally
  141.     seta  s "%parmline%" |S0=
  142.     compa "%s%" with ""
  143.     ifnequ send "%s%"
  144.  
  145.     #    Set name for logging
  146.     compa "%log%" with ""
  147.     ifnequ logname "%log%"
  148.     ifnequ logging 1
  149.  
  150.  
  151.     #    Wait for all Wn from PHONEBOOK and reply Sn
  152. :logloop
  153.     seta  w "%parmline%" |W%n%=
  154.     seta  s "%parmline%" |S%n%=
  155.     compa "%w%" with ""
  156.     ifequ goto finish
  157.  
  158.     rtrim w
  159.     rtrim s
  160.  
  161.     wait "%w%"
  162.     ifbrk writeln "Error: Did not receive '%w%'!!"
  163.     ifbrk goto finish
  164.  
  165.     delay
  166.     send "%s%"
  167.  
  168.     inc n
  169.     goto logloop
  170.  
  171.  
  172.  
  173.     ##################
  174.     #    THE END      #
  175.     ##################
  176. :finish
  177.     exit
  178.  
  179.  
  180. ####################################################
  181. # SUBROUTINES
  182. ####################################################
  183. :SayStatus
  184.     writeln "^[[H^[[1mXDIAL (Abort with Alt '-')^[[m"
  185.     writeln 
  186.     writeln "BOX    : %bbs%"
  187.     writeln "TRY    : %counter% "
  188.     writeln "STATUS : %status%                "
  189.     writeln "MODEM  : %last%                  "
  190.     return
  191.