Page 1 of 1

How to pass an ampersand variable value into a rexx variable

PostPosted: Tue Aug 10, 2010 12:53 pm
by oldnick
I need to get the length of a string in an ampersand variable that changes dynamically like a SCAN would read it

To get the idea of what I'm trying to do (but doesn't work obviously):

ADDRESS ISREDIT "(myvar) = &mydynamicvar"
say length(myvar)
or

ADDRESS ISREDIT var = length("&mydynamicvar")
say var

note that using just the mydynamicvar rexx variable is not what I want because it's not interpreted by the "ISREDIT" yet, I need to pass the interpreted value of &mydynamicvar like a SCAN would read it into a new rexx variable.

Is this possible ?

Thanks

Re: How to pass an ampersand variable value into a rexx variable

PostPosted: Wed Aug 11, 2010 1:47 am
by NicC
You have to exec your pgm in batch...

 EXEC 'XXX.YYYYYYY.EXEC(DJC)' 'a parm'

Re: How to pass an ampersand variable value into a rexx variable

PostPosted: Wed Aug 11, 2010 1:12 pm
by oldnick
Interesting, thanks

In the meantime I did it with some coding, I post it for others:

STR = "the string with the & variable"; BEFORE = "&ENVSRC."; AFTER = ENVSRC
DO FOREVER
POS = POS(BEFORE, STR)
IF POS == 0 THEN LEAVE
LB = LENGTH(BEFORE); LA = LENGTH(AFTER)
OVE = OVERLAY(AFTER, STR, POS)
STR = DELSTR(OVE, POS+LA, LB-LA)
END

Re: How to pass an ampersand variable value into a rexx variable

PostPosted: Wed Aug 11, 2010 1:45 pm
by Bala1
Hi Nic,
Thanks a lot for sharing the way to pass the parameters.
:-)

Re: How to pass an ampersand variable value into a rexx variable

PostPosted: Wed Aug 11, 2010 4:33 pm
by NicC
whoops - I see I posted my post to the wrong thread! Still, it helped someone!