REXX Tips & Tricks, Version 2.80


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


Check if a program is running (using RXU.DLL)





 
/* ------------------------------------------------------------------ */
/* function: isrun.cmd checks if a specific program is running        */
/*                                                                    */
/* Usage:    isrun exe_name                                           */
/*                                                                    */
/* returns:  0 - program is not running                               */
/*           1 - program is running                                   */
/*           2 - usage error                                          */
/*         255 - cannot load the DLL RXU                              */
/*                                                                    */
/*                                                                    */
/* Notes:    This program needs Dave Boll's DLL RXU.DLL               */
/*                                                                    */
/* Author:   Michael Platschek (see EMail Addresses)                  */
/*           Based on the program PI2.CMD from the RXU package        */
/*                                                                    */
/* see also Check if a program is running (using PSTAT)               */
/*                                                                    */
/*           You cannot check if a .CMD file is running with this     */
/*           routine!                                                 */
/*                                                                    */
                    /* get the parameter                              */
  parse upper arg progname
  if words( progname ) = 0 | words( progname ) > 1 | ,
     progname = '/?' | progname = '?' then
    SIGNAL PARAERR

  if rxfuncquery( 'rxqprocstatus' ) then
  do
                    /* load RXU DLL                                   */
    call rxfuncadd 'rxuinit', 'rxu', 'rxuinit'
    call rxuinit
  end /* if */

                    /* install an error handler for SYNTAX errors     */
  SIGNAL on SYNTAX Name DLLLoadError

                    /* get the stem with the process information      */
  call rxqprocstatus 'q.'

                    /* compare the name of the searched program with  */
                    /* all members of the stem with the running       */
                    /* processes                                      */
  do i = 1 to q.0P.0
    if progname = translate( filespec( 'n', q.0P.i.6 ) ) then
    do
                    /* program found                                  */
      RETURN 1
    end /* if */
  end /* do */

                    /* program NOT found                              */
RETURN 0

/* ------------------------------------------------------------------ */
/* show the usage help                                                */
PARAERR:
  say 'ISRUN <PROGRAMMNAME.EXT>'
  say ' Return-Codes:'
  say '   0 = program not running'
  say '   1 = program is running'
  say '   2 = invalid call'
  say ' 255 = Error loading the DLL RXU'
RETURN 2

/* ------------------------------------------------------------------ */
DLLLoadError:
  say 'Error: Cannot load the DLL RXU!'
RETURN 255

/* ------------------------------------------------------------------ */

  

Inf-HTML End Run - Successful