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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

External function Query

Status
Not open for further replies.

rajesh082

Programmer
Dec 18, 2007
38
DK
Hi All,

I have a small query.

I am calling a external user defined function in Rexx. Lets say that this external function B is being called by function A. The function B returns a variable 'alpha'.

My question is "Can I change the value of a variable 'Beta' in function B and use the changed value in function A?". Please note that the variable Beta here is different from the one that function B returns (Variable Alpha).

If my question is not clear pleae let me know, and I will post more details.
 
The variables in each function are independent of each other. FunctionB returns a value assigned to a variable, not the variable name. See the attached example.


/* REXX */
/* FuncA */
beta = 456
alpha = 'XYZ'
result = funcB()
say 'FunctionA' alpha beta result
exit

/* REXX */
/* FuncB */
beta = 123
alpha = 'ABC'
say 'FunctionB' alpha beta
Return alpha
 
Thanks Rxusr.
That means the variables have local scope rather than Global scope.

Can you give me any pointers how to make variables global in Rexx or better still how to pass the variables by reference so that I can use the modified value of variables in the original routine. If there are any other methods, used for achieving this functionality in Rexx, I would like to know that. Any kind of pointers will be appreciated.
 
I always prefer to use the stack for passing back data:
Code:
/* REXX A */
address TSO
"NEWSTACK"
"B"       /* invoke external B */
do queued()
   pull tag value
   $z    = Value(tag,value)  /* assign value to tag */
end 
"DELSTACK"
exit 

/* REXX B */
push 'size 42'
push 'color red'
push 'style ordinary run-of-the-mill'
exit


If you have an ISPF environment available, "A" can TBCREATE a table, "B" will write one or more rows consisting only of extension variables then return; "A" then does a TBTOP, TBGET and all the variables are magically populated in "A".



Frank Clarke
Support the Troops:
-- Bring them home.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top