IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Passing and returning a compound variable


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vasif

New User


Joined: 11 Feb 2008
Posts: 35
Location: Chennai

PostPosted: Tue Feb 09, 2010 1:56 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 09, 2010 2:08 pm
Reply with quote

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
View user's profile Send private message
vasif

New User


Joined: 11 Feb 2008
Posts: 35
Location: Chennai

PostPosted: Tue Feb 09, 2010 2:32 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 09, 2010 2:34 pm
Reply with quote

that' s exactly what I told You. icon_evil.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Passing Parameters to Programs Invoke... PL/I & Assembler 5
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Passing SYSPRINT to Invoked Program PL/I & Assembler 9
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
Search our Forums:

Back to Top