Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Passing and returning a compound variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Passing and returning a compound variable
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Feb 09, 2010 2:08 pm    Post subject: Reply to: Passing and returning a compound variable
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Feb 09, 2010 2:34 pm    Post subject: Reply to: Passing and returning a compound variable
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us