home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / os2page.zip / OS2PAGE.CMD next >
OS/2 REXX Batch file  |  1995-10-27  |  6KB  |  177 lines

  1. /* REXX */
  2. /* -------------------------------------------------------- */
  3. /* Procedure to call Alpha Paging system with message       */
  4. /* Author: John Manus 75777,2144                            */
  5. /* Date  : 09/08/95                                         */
  6. /*                                                          */
  7. /*              * * * * N O T E * * * *                     */
  8. /*                                                          */
  9. /*  * The strings that your pager service sends may not     */
  10. /*    match those that I've used here. Look at the statement*/
  11. /*    starting on line 117 to see if they meet your needs.  */
  12. /*    your needs.                                           */
  13. /*                                                          */
  14. /*  * Modem initialization strings can be found on line 52  */
  15. /*                                                          */
  16. /*              * * * * N O T E * * * *                     */
  17. /*                                                          */
  18. /* -------------------------------------------------------- */
  19.  
  20. TRACE E
  21.  
  22. arg Message
  23. call InitDefaults
  24. call ProcessPage
  25. call ClosePort
  26.  
  27. return
  28.  
  29.  
  30.  
  31. InitDefaults:
  32.  
  33.    DefaultSpeed       = "1200"
  34.    DefaultCOM         = "COM2"
  35.    DefaultPhone       = "0,0-000-000-0000"    /* Phone For Pager Service */
  36.    DefaultConnectWait = 55                    /* Timeout Value           */
  37.    DefaultPagerID     = "000-0000"            /* Your Pager ID           */
  38.  
  39.  
  40.    RetryIfBusy   = 3
  41.  
  42.    call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  43.    call sysloadfuncs
  44.  
  45.    /* Set default ARGS */
  46.  
  47.    ComPort = DefaultCOM
  48.    Phone = DefaultPhone
  49.  
  50.    State = STREAM(ComPort,"C","OPEN")
  51.    "@MODE" ComPort":"DefaultSpeed",E,7,1 > NUL"
  52.    StartTime = time('E')
  53.  
  54.    /* MODEM INITIALIZATION */
  55.    CALL LINEOUT ComPort, "ATZ"
  56.    ReturnStuff = " "
  57.    do until pos("OK",ReturnStuff) <> 0
  58.       ReturnStuff = ReturnStuff||CHARIN(ComPort)
  59.       if ((time('E') - StartTime) > DefaultConnectWait) then do
  60.         CALL LINEOUT ComPort,"ATH"                /* Hang Up */
  61.         State = STREAM(ComPort,"C","CLOSE")
  62.         Say "Sorry, Timeout... OK"
  63.         return
  64.         end
  65.    end
  66.  
  67.    CALL LINEOUT ComPort, "ATM0L0S11=50"
  68.  
  69.    ReturnStuff = " "
  70.    do until pos("OK",ReturnStuff) <> 0
  71.       ReturnStuff = ReturnStuff||CHARIN(ComPort)
  72.       if ((time('E') - StartTime) > DefaultConnectWait) then do
  73.         CALL LINEOUT ComPort,"ATH"                /* Hang Up */
  74.         State = STREAM(ComPort,"C","CLOSE")
  75.         Say "Sorry, Timeout... OK"
  76.         return
  77.         end
  78.    end
  79.    ReturnStuff = " "
  80.    /* say "Completed Modem Init" /* debug code */ */
  81. return
  82.  
  83.  
  84.  
  85. ProcessPage:
  86.    say "Message-"message
  87.    ReturnStuff = " "
  88.    CALL LINEOUT ComPort, "ATDT"Phone
  89.    z = 0
  90.    call charout ,"Dialing"
  91.    do until pos("CONNECT",ReturnStuff) <> 0
  92.       ReturnStuff = ReturnStuff||CHARIN(ComPort)
  93.       z = z + 1
  94.       remainder = z // 10
  95.       if remainder = 0
  96.          then do
  97.             call charout ,"."
  98.          end
  99.       if ((time('E') - StartTime) > DefaultConnectWait) then do
  100.         CALL LINEOUT ComPort,"ATH"                /* Hang Up */
  101.         State = STREAM(ComPort,"C","CLOSE")
  102.         Say "Sorry, Timeout... CONNECT"
  103.         return
  104.         end
  105.    end
  106.    say "Connected"
  107.  
  108.    ReturnStuff = " "
  109.    PosStart = 1
  110.    part1 = 0
  111.    part2 = 0
  112.    part3 = 0
  113.    part4 = 0
  114.  
  115.    DO until part1 & part2 & part3 & part4
  116.      ReturnStuff = ReturnStuff||CHARIN(ComPort)
  117.      if (pos('BUSY',ReturnStuff) <> 0) then do    /* Check for Busy */
  118.         CALL LINEOUT ComPort,"ATH"                /* Hang Up */
  119.         State = STREAM(ComPort,"C","CLOSE")
  120.         Say "Line Busy, Please Try Again..."
  121.         return
  122.         end
  123.  
  124.       select
  125.          when pos("ID=",ReturnStuff) <> 0
  126.             then do
  127.                call syssleep 1
  128.                call lineout ComPort,"M"
  129.                part1 = 1
  130.                returnstuff = " "
  131.                /* say "ID=...matched" /* debug code */ */
  132.             end
  133.          when pos("Pager ID, then RETURN.",ReturnStuff) <> 0
  134.             then do
  135.                call syssleep 1
  136.                call lineout ComPort,DefaultPagerID
  137.                part2 = 1
  138.                returnstuff = " "
  139.                /* say "Pager ID...matched" /* debug code */ */
  140.             end
  141.          when pos("Enter the Message, then RETURN.",ReturnStuff) <> 0
  142.             then do
  143.                call syssleep 1
  144.                call lineout ComPort,Message
  145.                part3 = 1
  146.                returnstuff = " "
  147.                /* say "Message...matched" /* debug code */ */
  148.             end
  149.          when pos("Thank You.",ReturnStuff) <> 0
  150.             then do
  151.                call syssleep 1
  152.                part4 = 1
  153.               "@MODE" ComPort":dtr=on > NUL"
  154.                /* say "Thank You...matched" /* debug code */ */
  155.                returnstuff = " "
  156.             end
  157.          otherwise nop
  158.       end
  159.       /* Check for timeout */
  160.       if ((time('E') - StartTime) > DefaultConnectWait) then do
  161.         CALL LINEOUT ComPort,"+++ATH"                /* Hang Up */
  162.         State = STREAM(ComPort,"C","CLOSE")
  163.         Say "Sorry, Timeout..."
  164.         return
  165.         end
  166.    END
  167. return
  168.  
  169.  
  170. ClosePort:
  171.    /* TRACE E */
  172.    CALL LINEOUT ComPort,"ATH"             /* Hang Up */
  173.    State = STREAM(ComPort,"C","CLOSE")
  174.    Say "Page Complete!"
  175. return
  176.  
  177.