/* */ /* Sample REXX code to show how to get the name of the main REXX */ /* program executed by the user. */ /* */ /* */ /* For example if the user calls TEST2.CMD and TEST2.CMD then calls */ /* TEST1.CMD, and finally TEST1.CMD calls this program, this progarm */ /* will print TEST2.CMD to the screen. */ /* (see also Get the invocation syntax) */ /* */ /* To test this code do */ /* */ /* - save it into a file named TEST.CMD */ /* */ /* - create another REXX program named TEST1.CMD containing the */ /* statements: */ /* */ /* parse source . . thisFile */ /* say 'This is "' || thisFile || '"' */ /* CALL TEST.CMD */ /* */ /* - create another REXX program named TEST2.CMD containing the */ /* statements: */ /* */ /* parse source . . thisFile */ /* say 'This is "' || thisFile || '"' */ /* CALL TEST1.CMD */ /* */ /* Then call TEST2.CMD with and without parameter to test this code */ /* */ /* check if this program was called as COMMAND */ /* or as SUBROUTINE */ parse source . callType . if callType <> "SUBROUTINE" then do say "Error: This method only works if this program was" , "called from another REXX program!" exit end /* if callType <> "COMMAND" then */ /* flush the REXX queue */ do while queued() <> 0; parse pull; end /* copy the name of the main CMD into the queue */ '@ECHO %0| rxqueue' parse pull invocation /* copy the parameter for the main CMD into the */ /* queue */ '@ECHO "%1 %2 %3 %4 %5 %6 %7 %8 %9"|rxqueue' parse pull parameter parameter = strip( strip( parameter, 'B', '"' ) ) parse arg thisArgs parse source . . thisFile say 'This is "' || thisFile || '"' say ' PARSE SOURCE says "' || thisFile || '"' say ' PARSE ARG says "' || thisArgs || '"' say ' The main program called was "' || invocation || '"' say ' The parameter for the main program are "' || parameter || '"' exit 0