home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / TE2OSB.ZIP / OSB.SCR next >
Text File  |  1992-08-31  |  7KB  |  226 lines

  1. ;; -------------------------------------------------------------------------
  2. ;; osb.scr -- Script for Os2shareware BBS           7/30/92 - 8/31/92
  3. ;;
  4. ;;      This is not an original work of mine!  I got most of it from
  5. ;;      scripts that came with Brady Flowers' TE/2v1.21. See `readmy' file
  6. ;;      that accompanies this one for important changes you may need.
  7. ;; -------------------------------------------------------------------------
  8.  
  9. global integer fGotBBS  ;; Caller must declare this global variable if he
  10. integer i               ;; wants to test the success or failure
  11.  
  12. ;string  DialerEntry = "OSB"           ;; <<== Change this for your setup
  13. string  MyName      = "James;Smith"    ;; <<== Change this to your name
  14. integer hWatch1
  15. integer hWatch2
  16.  
  17. string  QWKInbound  = "c:\dl"          ;; directory to which files go
  18. string  QWKOutbound = "c:\kwq"         ;; directory where qwk files are
  19. string  REPPacket   = "OS2SHARE.REP"
  20. string  buffer
  21. string  SaveDLPath
  22. integer SaveClobber
  23. integer SaveQZM
  24. integer SaveXonXoff
  25. integer fREPPacket
  26. integer fQWKPacket
  27. integer fp1
  28.  
  29. ;; -------------------------------------------------------------------------
  30.  
  31. subroutine GetBBS
  32.  
  33.   fGotBBS = FALSE  ;; All primed for failure
  34.  
  35.   ;; Try five times to cajole Bink into sending its initial banner by
  36.   ;; transmitting space characters, one every two seconds.
  37.   i = 0
  38.   do while i < 5
  39.     sendbyte(' ')
  40.     if waitfor("Address", 3)
  41.       break
  42.     else
  43.       i = i + 1
  44.       sleep(2000)
  45.     endif
  46.   loop
  47.  
  48.   ;; If i is less than 5, then we got the Bink banner, now do the same
  49.   ;; thing with ESCape characters to tell Bink we want the BBS.  See the
  50.   ;; comment above regarding testing for "Thank you" here.
  51.   if i < 5
  52.     i = 0
  53.     do while i < 5
  54.       sendbyte('^[')
  55.       if waitfor("Thank you", 3)
  56.         break
  57.       else
  58.         i = i + 1
  59.         sleep(2000)
  60.       endif
  61.     loop
  62.  
  63.     ;; If i is less than 5 here, it means Bink said "Thank you" and we
  64.     ;; should be going into the BBS now.
  65.     if i < 5
  66.       fGotBBS = TRUE
  67.     endif
  68.   endif
  69. endsub
  70.  
  71. ;;-----------------------------------------------------------------------------
  72.  
  73. subroutine MaxLogin
  74.  
  75.     if fGotBBS
  76.  
  77.       hWatch1 = watchfor("Press ENTER to continue", "sendbyte(13)")
  78.       hWatch2 = watchfor("More [Y,n,t,=]? ", "transmit(""Y^M"")")
  79.  
  80.       waitfor("What is your name:", 30)
  81.       transmit("%s;y;%s^M", myName, Password(""))
  82.       waitfor("o check for mail? [Y,n] ", 30)
  83.       transmit("n^M")                         ;; no mail check
  84.       LOGOPEN("c:\te2\osb.fil", 1)            ;; open log for new file list
  85.       waitfor("ck for new files? [Y,n] ", 30)
  86.       transmit("Y^M")                         ;; yes for new file listing
  87.       waitfor ("ress <enter> for ", 30)
  88.       transmit("^M")
  89.       waitfor("Select:", 300)
  90.  
  91.       cancelwatch(hWatch1)
  92.       cancelwatch(hWatch2)
  93.  
  94.     else
  95.       ;; Couldn't get thru Binkley for some reason?
  96.       Hangup(FALSE)
  97.     endif
  98. endsub
  99.  
  100. ;;-----------------------------------------------------------------------------
  101.  
  102. subroutine SetupQWK
  103.  
  104.   SaveDLPath     = DownLoadPath
  105.   SaveClobber    = ClobberDL
  106.   SaveQZM        = QueryZMRecover
  107.   SaveXonXoff    = XonXoff
  108.  
  109.   setxonxoff(0)
  110.   DownLoadPath   = QWKInbound
  111.  
  112.   ;; Possible settings for ClobberDL:
  113.   ;;   -1 -> rename an existing file and continue xfer
  114.   ;;    1 -> overwrite any existing file
  115.   ;;    0 -> abort xfer if file exists
  116.   ClobberDL      = 1
  117.   QueryZMRecover = FALSE
  118.   ;; Set ZModem recovery OFF, it would be a real pain to have the recovery
  119.   ;; menu pop up during an unattended transfer!
  120.  
  121.   ;; Discover if a .REP packet exists
  122.   REPPacket = QWKOutbound + "\" + REPPacket
  123.   fREPPacket = fopen(REPPacket, "r")
  124.   if (fREPPacket & 0x0000ffff)
  125.     fclose(fREPpacket)
  126.     fREPPacket = TRUE
  127.   else
  128.     fREPPacket = FALSE
  129.   endif
  130. endsub
  131.  
  132. ;; --------------------------------------------------------------------------
  133.  
  134. subroutine QWKXfer
  135.  
  136.   if fREPPacket
  137.     transmit("ou^M")                   ;; for Offline Reader to upload rep
  138.     waitfor("^Q", 300)
  139.     if upload(ZMODEM, REPPacket)
  140.       erase(REPPacket)
  141.     else
  142.       FileError("Error uploading file, aborting script! ", REPPacket)
  143.       stop
  144.     endif
  145.     waitfor("Select:", 300)
  146.     transmit("d^M")
  147.   else
  148.     transmit("od^M")
  149.   endif
  150.  
  151.   erase("c:\dl\os2share.old")                      ;; erases older qwk
  152.   rename("c:\dl\os2share.qwk", "\dl\os2share.old") ;; renames old qwk
  153.  
  154.   fQWKPacket = muxwait("/[Y,n]?/Select:/", 300)
  155.    if fQWKPacket == 1
  156.     transmit("Y^M")
  157.     waitfor("<esc> to abort:", 300)
  158.     transmit("^M")
  159.     waitfor("cancel.", 300)
  160.     download(ZMODEM, "")                           ;; auto zmodem download
  161.     waitfor("Select:", 300)
  162.    endif
  163. endsub
  164.  
  165. ;;------------------------------------------------------------------------------
  166.  
  167. subroutine UnSetupQWK
  168.  
  169.   DownLoadPath   = SaveDLPath
  170.   ClobberDL      = SaveClobber
  171.   QueryZMRecover = SaveQZM
  172.   setxonxoff(SaveXonXoff)
  173. endsub
  174.  
  175. ;;---------------------------------------------------------------------------
  176.  
  177. subroutine GetFile                             ;; this section downloads
  178.                                                ;; files listed in a .get
  179.     fp1 = fopen("c:\te2\scrip\osb.get", "r")   ;; file.
  180.      if (fp1 & 0xffff)
  181.        buffer = fgets(fp1)
  182.        fclose(fp1)
  183.        transmit("m^M")
  184.        waitfor("Select:", 60)
  185.        transmit("F^M")                         ;; file section
  186.        transmit("D %s^M", buffer)
  187.        waitfor("File(s) to download", 360)
  188.        transmit("^M")
  189.        waitfor("to cancel.", 300)
  190.        download(ZMODEM, "")
  191.        waitfor("Select:", 60)
  192.        erase("c:\te2\scrip\osb.get")           ;; erases get file so it
  193.      else                                      ;; can not be used again
  194.        gosub GetOff                            ;; accidently.
  195.      endif
  196. endsub
  197.  
  198. ;;------------------------------------------------------------------------------
  199.  
  200. subroutine GetOff
  201.  
  202.   transmit("g;y;n^M")
  203.   waitfor("Please call again!", 30)
  204.   LOGCLOSE()                                   ;; closes log
  205.   hangup(FALSE)
  206. endsub
  207.  
  208. ;;----------------------------------------------------------------------------
  209.  
  210. PROGRAM
  211.  
  212.   if !connected
  213.      hangup(FALSE)
  214.   endif
  215.  
  216.   if connected
  217.     gosub GetBBS
  218.     gosub MaxLogin
  219.     gosub SetupQWK
  220.     gosub QWKXfer
  221.     gosub UnSetupQWK
  222.     gosub GetFile
  223.     gosub GetOff
  224.   endif
  225. end
  226.