Get the parameters as seen by CMD.EXE - 2 -

[Autolink] Menu

 
/*                                                                    */
/* sample REXX code to show how to get the parameter without          */
/* using the REXX functions (and therefore avoiding the restrictions  */
/* of the REXX interpreter)                                           */
/*                                                                    */
/* Caution: This code works only for REXX programs called from        */
/*          CMD.EXE - not for REXX programs called from other         */
/*          REXX programs!                                            */
/*                                                                    */
/* see also Get the parameters as seen by CMD.EXE                     */
/*                                                                    */

                    /* check if this program was called as COMMAND    */
                    /* or as SUBROUTINE                               */
  parse source . callType .
  if callType <> "COMMAND" then
  do
    say "Error: This method only works if this program was" ,
        "called from the command line!"
    exit
  end /* if callType <> "COMMAND" then */

                    /* copy the parameters 1 to 9 into an environment */
                    /* variable                                       */
  '@SETLOCAL'
  '@SET MYVAR=%1 %2 %3 %4 %5 %6 %7 %8 %9'
                    /* get the parameter via the alternate method     */
  CMDParameter = strip( value( 'MYVAR',, 'OS2ENVIRONMENT' ) )
  '@ENDLOCAL'

                    /* get the parameter via the REXX features        */
  parse arg REXXParameter

  say 'Parameter retrieved with PARSE ARG are:       "' || REXXParameter || '"'
  say 'Parameter retrieved via alternate method are: "' || CMDparameter || '"'
exit 0


[Back: Get the parameters as seen by CMD.EXE]
[Next: Check if a program is running (using RXU.DLL)]