REXX Tips & Tricks, Version 2.80

Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs

Start an OS/2 program synchronously

Some PM programs (for example VIEW.EXE and NOTES.EXE) start asynchronously 
if called from a REXX program. Use the following code to start one of 
these programs and wait until it ends (You can also use this technique for 
a simple Process controller in REXX; see also Start a Windows program 
synchronously and StartDOS): 

/* sample code to start an OS/2 program synchronously                 */

                    /* load the necessary REXXUTIL function(s)        */
  call rxFuncAdd "SysSleep", "REXXUTIL", "SysSleep"

                    /* name of the "semaphore" file                   */
                    /* Note: If you want to run this program in       */
                    /*       separate sessions at the same time, use  */
                    /*       a routine that lets you get a unique     */
                    /*       name for a temporary file, to get a      */
                    /*       unique name for your semaphore files.    */
                    /*       (for example                             */
                    /*       Get a name for a temporary file)         */
  SemFile = "TEST.SEM"

                    /* start the program and redirect STDOUT into the */
                    /* "semaphore" file                               */
  "view cmdref.inf >" || semFile

                    /* wait until the program ends                    */
  do until stream(  semFile, "c", "OPEN READ" ) = "READY:"
    call SysSleep 1
  end /* do until ... */

                    /* close and delete the "semaphore" file          */
  call stream semFile, "c", "CLOSE"
  "del " semFile "2>NUL 1>NUL"
exit 0


Inf-HTML End Run - Successful