Passing Stem Variable between Procedures.



IBM's Command List programming language & Restructured Extended Executor

Passing Stem Variable between Procedures.

Postby bazzigar » Mon Jul 02, 2012 6:03 am

Hello,

take a look at the below program and please tell me wats wrong in that,
I want the output like,
Hello One
Hello Two
Hello Three
Hello There again

/*REXX*/
Var1.1='Hello One'
Var1.2='Hello Two'
Var1.3='Hello Three'
Var3="Hello There again"
Call SayThat Var1.,Var3
SayThat:Procedure
Count.=ARG(1)
Do i=1 to 3
Say Count.i
End
Say ARG(2)

But the actual output like below,

VAR1.
VAR1.
VAR1.
Hello There again

Thanks,
bazzigar
 
Posts: 29
Joined: Sat Feb 11, 2012 7:20 am
Has thanked: 0 time
Been thanked: 0 time

Re: Passing Stem Variable between Procedures.

Postby Pedro » Thu Jul 05, 2012 9:34 pm

The PROCEDURE statement fences off variables. The statements within the procedure cannot reference the variables outside of the procedure, without specifying in the PROCEDURE EXPOSE clause. But using EXPOSE makes passing in the name of the stem less attractive.

Try the same (more or less) without PROCEDURE:
/*REXX*/                 
Var1.1='Hello One'       
Var1.2='Hello Two'       
Var1.3='Hello Three'     
Var3="Hello There again"
Call SayThat Var1.,Var3 
Exit                     
                         
SayThat:                 
Count=ARG(1)             
Do i=1 to 3             
 Interpret "Say "Count"i"
End                     
Say ARG(2)               


The other odd thing is that Var1. is a valid variable, different from the var1.x set of variables. But for uninitialized variables, rexx uses the name of the variable as its value (same as: abc ='abc' ). I think it is poor practice to rely on uninitialized variables, so perhaps use a quoted string instead:
Call SayThat 'Var1.',Var3
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: Passing Stem Variable between Procedures.

Postby bazzigar » Fri Jul 06, 2012 10:19 am

Pedro wrote:The PROCEDURE statement fences off variables. The statements within the procedure cannot reference the variables outside of the procedure, without specifying in the PROCEDURE EXPOSE clause. But using EXPOSE makes passing in the name of the stem less attractive.

Try the same (more or less) without PROCEDURE:
/*REXX*/                 
Var1.1='Hello One'       
Var1.2='Hello Two'       
Var1.3='Hello Three'     
Var3="Hello There again"
Call SayThat Var1.,Var3 
Exit                     
                         
SayThat:                 
Count=ARG(1)             
Do i=1 to 3             
 Interpret "Say "Count"i"
End                     
Say ARG(2)               


The other odd thing is that Var1. is a valid variable, different from the var1.x set of variables. But for uninitialized variables, rexx uses the name of the variable as its value (same as: abc ='abc' ). I think it is poor practice to rely on uninitialized variables, so perhaps use a quoted string instead:
Call SayThat 'Var1.',Var3





Thank you so much Pedro for yor reply.It helps me.
bazzigar
 
Posts: 29
Joined: Sat Feb 11, 2012 7:20 am
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post