home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / RXCOMM.ZIP / REXCOMM.CMD < prev    next >
OS/2 REXX Batch file  |  1990-12-23  |  4KB  |  120 lines

  1. /* 09-27-90                                                 M.C. Smith */
  2. /***********************************************************************/
  3. /*                           RexCOMM.CMD                               */
  4. /* Purpose: test the functions of the RxCOMM dll package.  Creates a   */
  5. /*          "dumb" terminal program in REXX using the comm DLL.        */
  6. /*                                                                     */
  7. /* NOTE:  This code has been released into the Public Domain by the    */  
  8. /*        author.  This code has NOT been extensivly tested, being a   */
  9. /*        3 hour development project that was abandoned due to the     */
  10. /*        performance of the REXX interpreter under OS/2.  If you find */
  11. /*        any bugs, or would like to contact the author, he can           */
  12. /*        be reached at:                                               */
  13. /*                                                                     */
  14. /*   Copyright (c) 1990 by:     Mark C. Smith                          */
  15. /*                              2638 Marrietta                         */
  16. /*                              Farmersvilles, Tx 75234                */
  17. /*                                                                     */
  18. /*                              214/484-4470                           */
  19. /*                                       */
  20. /*                                                                     */
  21. /***********************************************************************/
  22.  
  23.  Address CMD                       /* Pass all commands to environment */
  24.  Arg handle               /* Should be our COM port           */
  25.  
  26.  call Initial
  27.  
  28.  Do FOREVER
  29.    If chars() > 0 Then            /* Characters available at keyboard? */
  30.      Do
  31.        char = RxGetChar(NOECHO)
  32.        If char = 'F1' Then
  33.          Leave
  34.        Else
  35.          call RxCommPut handle, char
  36.      End  /* IF chars() > 0 */
  37.  
  38.    If RxCommCheck(handle) > 0 Then
  39.      Call RxSay RxCommGet(handle)
  40.  
  41.  End /* Do FOREVER */
  42.  
  43. /* Ending - close our comm port                                        */
  44.  
  45.  call RxCommClose handle
  46.  
  47. '@Cls'
  48.  
  49.  Say 'REXXCOMM ended successfully'
  50.  
  51.  EXIT 0
  52.  
  53. /************************************************************************/
  54. /* LoadFunctions:  load our DLL library and register it with REXX/SAA   */
  55. /************************************************************************/
  56.  
  57. LoadFunctions:
  58.  
  59.  call RxFuncAdd 'RxCommOpen'     , 'RXCOMM', 'RXCOMMOPEN'
  60.  call RxFuncAdd 'RxCommClose'    , 'RXCOMM', 'RXCOMMCLOSE'
  61.  call RxFuncAdd 'RxCommPut'      , 'RXCOMM', 'RXCOMMPUT'
  62.  call RxFuncAdd 'RxCommGet'      , 'RXCOMM', 'RXCOMMGET'
  63.  call RxFuncAdd 'RxCommGetParams', 'RXCOMM', 'RXCOMMGETPARAMS'
  64.  call RxFuncAdd 'RxCommSetParams', 'RXCOMM', 'RXCOMMSETPARAMS'
  65.  call RxFuncAdd 'RxCommSendBreak', 'RXCOMM', 'RXCOMMSENDBREAK'
  66.  call RxFuncAdd 'RxCommCheck'    , 'RXCOMM', 'RXCOMMCHECK'
  67.  call RxFuncAdd 'RxCommSetDTR'   , 'RXCOMM', 'RXCOMMSETDTR'
  68.  call RxFuncAdd 'RxCommFlush'    , 'RXCOMM', 'RXCOMMFLUSH'
  69.  call RxFuncAdd 'RxGetChar'      , 'RXCOMM', 'RXGETCHAR'
  70.  call RxFuncAdd 'RxSay'          , 'RXCOMM', 'RXSAY'
  71.  
  72.  Return
  73.  
  74. /*************************************************************************/
  75. /* Initial:  set up our environment                                      */
  76. /*************************************************************************/
  77.  
  78. Initial:
  79.  
  80.  blank = ' '
  81.  true  = 1
  82.  false = 0
  83.  
  84.  ocd = blank
  85.  
  86.  handle = Strip(handle)
  87.  
  88.  If SubStr(handle,1,3) \= 'COM' Then
  89.    Do
  90.      Say 'RexComm:  Unknown COMM port.'
  91.      Say
  92.      Say 'Usage   RexComm x'
  93.      Say '        where x is a valid comm port'
  94.      Exit 98
  95.    End /* If handle = '' | handle = '?' */
  96.  
  97.  call LoadFunctions
  98.  
  99. '@Cls'
  100.  
  101.  Say 'REXX/SAA COMM version 1.00 test program'
  102.  
  103. /* Open the Communications port - theoretically we SHOULD test the result */
  104. /* since the port might be in use by another process.  However, as this   */
  105. /* is just a test, I will not.  Note that RxCommOpen() will return a bad  */
  106. /* return code on failure (-2).                                           */
  107.  
  108.  call RxCommOpen handle
  109.  
  110. /* Set up our comm port to the proper baud rate etc.                      */
  111.  
  112.  call RxCommSetParams handle, 2400, 8, 'NONE', 1
  113.  
  114.  Say "Press 'F1' to end communications."
  115.  Say
  116.  
  117. '@Ansi ON'
  118.  
  119.  Return
  120.