Get the invocation syntax

[Autolink] Menu

 
/*                                                                    */
/* sample REXX code to show how to get the invocation syntax          */
/* (PARSE SOURCE always returns the fully qualified name of the       */
/*  REXX program)                                                     */
/*                                                                    */
/* Using this code, you can determine what command the users entered  */
/* to call your REXX program.                                         */
/*                                                                    */
/* e.g. TEST.CMD or .\TEST.CMD or D:\REXX\TEST.CMD                    */
/*                                                                    */
/* To test this code call it with different name/path combinations    */
/* e.g.:                                                              */
/*                                                                    */
/*  test.cmd                                                          */
/*  .\test.cmd                                                        */
/*  or                                                                */
/*  d:\rexx\test.cmd                                                  */
/*                                                                    */
/* 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 name of the MAIN program called)        */
/*                                                                    */

                    /* 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 invocation syntax into the queue      */
  '@ECHO %0| rxqueue'

  parse pull invocation

  parse source . . thisFile

  say 'PARSE SOURCE says "'  || thisFile || '"'
  say 'The program was called via "' || invocation || '"'
exit 0


[Back: Get the current OS/2 version (w/o REXXUTIL)]
[Next: Get the name of the MAIN REXX program called]