REXX Tips & Tricks, Version 2.80

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

Start a Windows program synchronously

To start a Windows program synchronously, you must use a DOS batch file. 
The batch file might look like (see also Start an OS/2 program 
synchronously and StartDOS): 

REM *** DOS Batch
REM     Usage: DOSSTART.BAT semFile windowsProgram {progParameters}
SET semFile=%1
SET programName=%2
SET parameter=%3
SET parameter=%parameter% %3
IF NOT "%3" == "" GOTO pLoop

%programName% %parameter% >%semFile%

The calling REXX program might look like 

/* sample code to start a Windows program synchronously               */

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

                    /* name of the "semaphore" file                   */
                    /* Note: Use a routine like for example           */
                    /*       Get a name for a temporary file          */
                    /*       to get a unique name for the semaphore   */
                    /*       file if you want to run this program     */
                    /*       in separate sessions at the same time.   */
  semFile = 'd:\sem'
  winProg = 'd:\win\apps\excel4\excel'
  'DOSSTART.BAT' semFile winProg
   do forever
      say 'Waiting for the Windows Session ... '
      if stream( semFile, 'c', 'OPEN READ' ) = 'READY:' then
       call SysSleep 1

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


Inf-HTML End Run - Successful