home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / TE2HOST.ZIP / WAIT4CAL.SCR < prev   
Text File  |  1990-12-27  |  2KB  |  79 lines

  1. ;; --------------------------------------------------------------------------
  2. ;;
  3. ;; Wait4Cal.scr -- Host mode script suite for TE/2
  4. ;;                 Copyright 1990, Oberon Software, All rights reserved
  5. ;;
  6. ;; --------------------------------------------------------------------------
  7.  
  8. global  integer MaximumBaud
  9. global  integer smMenuExit
  10.  
  11. string  answerCall   = "ATA^M"
  12. string  Reliable9600 = "9600/ARQ"
  13.  
  14. integer WaitCallD1   = 20   ;; Time (seconds) spent in waitfor
  15. integer WaitCallD2   = 1    ;; Time (seconds) spent between waitfors
  16. integer callerBaud          ;; Current user baud rate
  17. string  mdmResponse         ;; Standard Modem Response
  18.  
  19.   ;; ------------------------------------------------------------------------
  20.   ;; WaitForCall uses a polling method of waiting, waiting for a "RING"
  21.   ;;  string from the modem rather than activating AutoAnswer.  Currently
  22.   ;;  there is no reason to do this as opposed to using the modem's
  23.   ;;  built in AutoAnswer and waiting for "CARRIER" with an infinite
  24.   ;;  timeout.  However, WATCHFORs (which really aren't applicable here)
  25.   ;;  and SCHEDULEd events (which are, when they are implimented, that is)
  26.   ;;  only get to execute in between statments in the currently running
  27.   ;;  script file.
  28.  
  29. subroutine WaitForCall
  30.  
  31.   do while !connected
  32.     message("Waiting ..... %s^M", strtime)
  33.     if waitfor("RING", WaitCallD1)
  34.       transmit("%s", answerCall)
  35.       if waitfor("CONNECT", 30)
  36.         mdmResponse = rgets(255, 15, FALSE)
  37.         if strstr(mdmResponse, Reliable9600) == 0
  38.           callerBaud = atoi(mdmResponse)
  39.           if callerBaud == 0
  40.             callerBaud = 300
  41.           endif
  42.           if callerBaud != maximumBaud
  43.             setParms(-1, callerBaud, -1, -1, -1)
  44.           endif
  45.         else
  46.           callerBaud = maximumBaud
  47.         endif
  48.         message("^M^JCarrier Detected at %d^M^J", callerBaud)
  49.         break
  50.       else
  51.         hangup(FALSE)
  52.         sleep(WaitCallD2 * 1000)
  53.       endif
  54.  
  55.     elseif timedout
  56.       sleep(WaitCallD2 * 1000)
  57.  
  58.     else
  59.       run("menu_loc")
  60.       if smMenuExit
  61.         break
  62.       else
  63.         cls()
  64.         message("TE/2 Host Script^M^J")
  65.         message("Waiting for call...^M^J")
  66.       endif
  67.  
  68.     endif
  69.   loop
  70.  
  71. endsub
  72.  
  73.  
  74.  
  75. program
  76.   gosub WaitForCall
  77.   end
  78.  
  79.