View previous topic :: View next topic
|
Author |
Message |
vasif
New User
Joined: 11 Feb 2008 Posts: 35 Location: Chennai
|
|
|
|
Hi,
I wrote a procedure where i am passing a compound variable 'list1.'.
Heres the procedure:
Code: |
call getList list1.
call getList list2.
getList:
arg list.
i=1
do while i < 5
list.i = i
i = i + 1
end
list.i = 'end'
return
|
But after the procedure executes, list1 & list2 dont show the expected output. I dont want to use PROCEDURE EXPOSE as it will make the 'list.' global to the rexx pgm. Moreover, i want the getList subroutine to be generic where i can pass an empty compound variable and get a filled in list after return. I even tried using Function instead of subroutine, it didnt work. Any solutions apart from duplicating the subroutine for 'list2.'? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
it cannot be done full stop
not using ... the procedure construct will globalize the main environment to the subroutine/function anyway
also exposing will simply let You have full access to the exposed variables without the need of passing them as parms
giving You the (almost ) same environment as in the first case
the whole process should be reviewed, but with only what You have told it is not easy to give a good advice
one solution would be ...
1) not use the procedure construct
2) pass the name of the stem
3) use the INTERPRET instruction
something along the lines of
Code: |
sub:
parse arg stemname
do i = 1 to count
interpret stemname"."i " = " i
end
interpret stemname".0 = " count
return
|
the standard for stems is to keep the number of stem entries in the .0 <thing>
so no need for a termination flag |
|
Back to top |
|
|
vasif
New User
Joined: 11 Feb 2008 Posts: 35 Location: Chennai
|
|
|
|
Thank you enrico for the quick response.
So can i conclude that the below code cant be realised at all in rexx
Code: |
call sub stem1.
call sub stem2.
|
and expect stem1 and stem2 to have a list of 1 to count each? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
that' s exactly what I told You. |
|
Back to top |
|
|
|