home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxtech03.zip / VXTECH03.TXT
Text File  |  1994-03-10  |  5KB  |  154 lines

  1. ============================================================================
  2.  VX-REXX Tech Note #3:                           
  3.                      Using the REXX Queue to start VIO programs
  4.  
  5.                                                           February 16, 1994
  6.  
  7.                      Applies to all versions of VX-REXX
  8. ----------------------------------------------------------------------------
  9.  
  10.                                                        Paul Prescod
  11.                                                        WATCOM International
  12.  
  13. ============================================================================
  14.  
  15. Abstract
  16. --------
  17.  
  18. Certain programs require OS/2 VIO support to run.  Since VX-REXX provides
  19. only a Presentation Manager environment, these programs must be run in a
  20. seperate session using the "Start" command.  This may introduce unwanted
  21. concurrency issues.  A function StartVIO is provided to resolve these
  22. issues.
  23.  
  24.  
  25. Recognizing Programs that require VIO Support
  26. ---------------------------------------------
  27.  
  28. Some OS/2 text mode programs require certain VIO functions that are not
  29. provided in a Presentation Manager environment. For example, the OS/2 PSTAT 
  30. command relies on VIO support.  If you try to run it within a VX-REXX 
  31. program, you will get a "SYS0436: An invalid VIO handle was found" error.
  32.  
  33. Other programs which exhibit this problem are the CM/2 SEND.EXE and
  34. RECEIVE.EXE programs, and the SPF/2 editor.  Unfortunately, the error
  35. message varies, so it is not always easy to recognize that the problem
  36. is caused by the fact that VX-REXX programs are Presentation Manager
  37. based.
  38.  
  39. The easy way to check is to make a small REXX TEST.CMD file which runs
  40. the program, i.e.
  41.  
  42. /* Test program */
  43. 'send filename'
  44.  
  45. Run it from the command line like this:
  46.  
  47. [C:\] test.cmd
  48.  
  49. Then run it in a Presentation Manager session like this:
  50.  
  51. [C:\] pmrexx test.cmd
  52.  
  53. If it works in the first case, but not the second, the program is probably
  54. dependant on VIO support.
  55.  
  56. OS/2 Start
  57. ----------
  58.  
  59. The easiest way to get around VIO problems is the OS/2 "Start" command 
  60. which allows you to launch any program in a different session.  Using start
  61. you can launch VIO programs from PM or vice versa.  More information on the
  62. using the start command from within VX-REXX can be found in the VX-REXX 
  63. Read Me First in the section "Tips", "Launching Programs from REXX."  
  64. The start command has many command line switches to specify the type of
  65. program to run and the type of window (full screen, minimized etc.) to run
  66. it in. There is more information on  the start command features in the 
  67. OS/2 Command Reference object in the information folder. If you are 
  68. familiar with the start command, however, you will know that it runs the 
  69. new process concurrently (at the same times as) the current program.  If 
  70. this is a problem, you must force the original program to halt until the 
  71. second program exits.  Because these two programs are in different 
  72. processes, the most efficient way to do this is the standard REXX 
  73. interprocess communication facility, a REXX queue.
  74.  
  75. StartVIO
  76. --------
  77.  
  78. StartVIO, listed below, is a REXX function which you can add to your 
  79. programs to start a text mode process, halt the main program until it 
  80. returns, and send the return code via a REXX queue.  StartVIO and RUN.CMD 
  81. are simple enough that you can modify them if they don't fit your needs.  
  82. They also serve as a good example of the power of REXX queues.  For more 
  83. information on REXX queues, read the chapter "Queue Interface" in the 
  84. online "REXX Information" reference in the VX-REXX folder.
  85.  
  86.  
  87. Syntax
  88. -----
  89.  
  90. rc = StartVIO(command)
  91.  
  92.  
  93. Setup
  94. -----
  95.  
  96. You must add the StartVIO function to your program, and put the run.cmd
  97. program in your path.  To add StartVIO to your program, you can cut and
  98. paste it somewhere in your project.  Do not add run.cmd to your file or
  99. project. Start is an OS/2 command interpreter command, and not a VX-REXX 
  100. or REXX command.  So run.cmd must be somewhere in the path so that the 
  101. command interpreter can find it.
  102.  
  103.  
  104. Example
  105. -------
  106. This example runs the OS/2 pstat command, stores its return code in the
  107. variable called rc, and prints rc.
  108.  
  109.     rc = StartVIO("Pstat")
  110.     say rc
  111.  
  112.  
  113.  
  114.  
  115. Code
  116. ----
  117. ----------------------------------------------------
  118.  
  119. StartVIO:procedure
  120. /* Run a VIO program synchronously */
  121. /* Should be part of your program */
  122. parse arg command
  123.  
  124.     /* Create queue */
  125.     queue = RXQueue( "Create" )
  126.     oq = RXQueue( "Set", queue )
  127.     
  128.     "start /win /c run.cmd" queue command "<con >con"
  129.     
  130.     /* Wait */
  131.     rc = linein( "QUEUE:" )
  132.     
  133.     
  134.     /* Destroy Queue */
  135.     call RXQueue "Set", oq
  136.     call RXQueue "Delete", queue
  137.     
  138. return rc
  139.  
  140. ----------------------------------------------------
  141.  
  142. /* run.cmd - run program and signal completion on rexx queue */
  143. /*           Should be in your path  */
  144. Main:
  145.     parse arg queue commands
  146.  
  147.     commands
  148.     retval = rc
  149.     call RXQueue "Set", queue
  150.     push rc
  151. return
  152.  
  153.  
  154.