Get the parameters as seen by CMD.EXE

[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 - 2 -               */
/*                                                                    */

                    /* 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 */

                    /* flush the REXX queue                           */
  do while queued() <> 0; parse pull; end

                    /* copy the parameters 1 to 9 into the queue      */
                                                             /* v3.20 */
  '@IF NOT %1. == . ECHO %1 %2 %3 %4 %5 %6 %7 %8 %9| rxqueue'
                    /* get the parameter via the alternate method     */

   if queued() <> 0 then                                     /* v3.20 */
     parse pull CMDparameter                                 /* v3.20 */
   else                                                      /* v3.20 */
     CMDParameter = ''                                       /* v3.20 */

   CMDParameter = strip( CMDParameter )

  parse pull CMDparameter
  CMDParameter = strip( CMDParameter )

                    /* 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 name of the MAIN REXX program called]
[Next: Get the parameters as seen by CMD.EXE - 2 -]