Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to find out the caller of a REXX-procedure

Status
Not open for further replies.

Adam5

Programmer
Joined
Oct 13, 2005
Messages
18
Location
DE
Hello,

I need to find out which REXX-procedure calls the aktual REXX-procedure.

For example REXX-procedure TEST1 calls TEST2:


REXX-procedure TEST1:
Code:
/* REXX */
call TEST2

REXX-procedure TEST2:
Code:
/* REXX */
whocallsme = ????? 
say 'I was called from ' whocallsme
The result should be:
Code:
I was called from TEST1

Thanks

 
The have the caller pass its name to the called routine.


Nic
 
Maybe pass the caller name as argument to the called procedure.
 
Or you can use REXX stack to transfer caller name - example:

rx_pgm01.rex
Code:
parse source opsys envir pgm_name
pgm_name = upper(pgm_name)
say "* This program name: '" pgm_name "'"

/* show caller name */
if queued() \= 0 then do
  pull caller_name
  say "      called from: '" upper(caller_name)"'" 
end

/* push this program's name */
push pgm_name

/* call other pgm */
call rx_pgm02

rx_pgm02.rex
Code:
parse source opsys envir pgm_name
pgm_name = upper(pgm_name)
say "* This program name: '" pgm_name "'"

/* show caller name */
if queued() \= 0 then do
  pull caller_name
  say "      called from: '" upper(caller_name)"'" 
end

/* push this program's name */
push pgm_name

/* call other pgm */
call rx_pgm03

rx_pgm03.rex
Code:
parse source opsys envir pgm_name
pgm_name = upper(pgm_name)
say "* This program name: '" pgm_name "'"

/* show caller name */
if queued() \= 0 then do
  pull caller_name
  say "      called from: '" upper(caller_name)"'" 
end

/* push this program's name */
push pgm_name

/* call other pgm */
/*call rx_pgm03 */
...
...
etc

Output:
Code:
c:\Work>rexx rx_pgm01.rex
* This program name: ' C:\WORK\RX_PGM01.REX '
* This program name: ' C:\WORK\RX_PGM02.REX '
      called from: ' C:\WORK\RX_PGM01.REX'
* This program name: ' C:\WORK\RX_PGM03.REX '
      called from: ' C:\WORK\RX_PGM02.REX'
It works with both REXXes I have here: OORexx and Regina.
 
I don't like the usage of the stack. Therefore I think, I'll use the "parse source" to get the name of the running exec, and pass that as a argumtent to the called procedure.

Thank's a lot![smile]
 
External data queue is a neat feature of REXX. I like it :-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top