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
 

 

How to Pass Array to subroutines.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Tue Feb 05, 2008 11:29 pm    Post subject: How to Pass Array to subroutines.
Reply with quote

I have a array called SYM.0 in the main program and I need to pass the array variable to another subroutine.

How can i do this.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Feb 05, 2008 11:48 pm    Post subject: Reply to: How to Pass Array to subroutines.
Reply with quote

the subroutine must be in the same source file,
snippet...

subroutine:procedure expose sym.
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Wed Feb 06, 2008 1:12 am    Post subject:
Reply with quote

Yes they are in the same source file.'

This is how I have passed.

Code:
ADDRESS ISPEXEC "VPUT (DSNSTMT SYM) PROFILE"
CALL DSNPROCS                               


This is how i am getting it.

Code:
ADDRESS ISPEXEC "VGET (DSNSTMT SYM) PROFILE"


I am not clear with the one you have said earlier.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Feb 06, 2008 1:58 am    Post subject: Reply to: How to Pass Array to subroutines.
Reply with quote

maybe Your request was not very clear to me
I inferred that in the main flow You had an array ...
improper term for a stemmed variable
and You wanted to use the same in a subroutine

Code:
....
sym.0 = 2
sym.1 = "one"
sym.2 = "two" 

do i = 1 to sym.0
   say "mainprog  " i sym.i
end

say "calling mysub"
call mysub

exit

mysub:procedure expose sym.
do i = 1 to sym.0
   say "mysub    " i sym.i
end
return


but from Your second post i see that You are passing by using ispf vput service
a simple variable called SYM, not ann array or a stem...

please clarify
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Wed Feb 06, 2008 4:59 am    Post subject:
Reply with quote

You are correct I have passed just the SYM as if I was passing the SYM.0 it was throwing me an error using the ISPEXEC.

So I was trying different option.

I tried your way of using the procedure.

First program TEST

Code:
/**REXX*/                                         
DSNAME.1='&HLQV.SECU.ABCP.DRIVER'                 
DSNAME.2='&HLQ.&SYS..&JOB..NOTPSTED.REPORT'       
DSNAME.3='&HLQV&VER&SYS..POST20.TEMP.LTRQ.CLUSTER'
DSNAME.4='&HLQ.&LSCID..&RCVR.&SNDR.VERI.RESPONSE'
DSNAME.0 = 4                                     
                                                 
  CALL TEST1                 
EXIT(0)
 


The TEST1 Program

Code:
/* REXX */                     
 TEST1:PROCEDURE EXPOSE DSNAME.
                               
 DO I = 1 TO DSNAME.0         
    SAY 'DSNAME' DSNAME.I     
 END                             
RETURN
 



When i run the TEST program its showing me Error as

2 +++ PROCEDURE EXPOSE DSNAME.
IRX0017I Error running TEST1, line 2: Unexpected PROCEDURE
8 +++ CALL TEST1



I am not sure If I was clear with my question I am sorry.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Wed Feb 06, 2008 12:04 pm    Post subject:
Reply with quote

Krishna -

As Enrico already said, "the subroutine must be in the same source file", that is - your main routine and your called subroutine should be in the same member in order to use the PROCEDURE instruction (as clearly noted in the fine manual).

If you want to pass arrays to external subroutine, you need to compose your own logic. For this, you can
- Use the QUEUE
- Write to dataset (probably temporary)
- Use VPUT/VGET with INTERPRET
- Concatenate the values into one string with delimiter in between
- Use the variable access routine IKJCT441
etc...

O.
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Wed Feb 06, 2008 7:33 pm    Post subject:
Reply with quote

As I already mentioned both the TEST and TEST1 member are in the same PDS.

or the main routine and the subroutine are in the same source.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Feb 07, 2008 6:20 pm    Post subject: Reply to: How to Pass Array to subroutines.
Reply with quote

what we meant was that ...

main and subroutines ( for expose to work ) must be in the same source member

not... different members of the same source PDS
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Feb 07, 2008 10:35 pm    Post subject: Reply to: How to Pass Array to subroutines.
Reply with quote

If You need to pass stems across rexx scripts, search the net with
"STEMPUSH" and/or "STEMPULL"
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Thu Feb 07, 2008 10:41 pm    Post subject: Reply to: How to Pass Array to subroutines.
Reply with quote

You know, this is the second post by this O/P on this same topic. All of these answers were given the first time too.

I really don't get what the big deal is with just writing the data to a temp (VIO) dataset from one exec, and reading it from a different exec or clist. They can go back-and-forth all day long like this.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Feb 07, 2008 10:58 pm    Post subject: Reply to: How to Pass Array to subroutines.
Reply with quote

the other time He was asking about simple variables,
and the VPUT/VGET approach was viable

not the same thing for stem, if the subroutine is getting called
let' s say, for each record read, then the performance would be horrible..
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Feb 07, 2008 11:01 pm    Post subject:
Reply with quote

Quote:
not the same thing for stem, if the subroutine is getting called
let' s say, for each record read, then the performance would be horrible..

That's a good reason to use an internal subroutine, or to use COBOL with IKJCT441 ....

O.
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Fri Feb 08, 2008 2:20 am    Post subject: Reply to: How to Pass Array to subroutines.
Reply with quote

I dont think I have raised the this question in another post of mine. If I misunderdtood I am sorry.

The code that I have showed in here is just a example actually I need to know how to pass the stem variable which will be used in my code which is too big to post here.

thanks for the input I will search for STEMPUSH and PULL
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Feb 08, 2008 7:58 am    Post subject:
Reply with quote

Hello,

Quote:
I need to know how to pass the stem variable which will be used in my code which is too big to post here.
You might consider making a much smaller bit of code to test passing the variable. Once the test works, incorporate the method that works for you into the main code.
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Fri Feb 08, 2008 9:51 am    Post subject:
Reply with quote

Yes I will do that way, but I am not sure how to pass the stem variable across program.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Feb 08, 2008 8:11 pm    Post subject:
Reply with quote

Hello,

If you build the 2 "test" sets of code (using the suggestions above) and have questins/problems, you could post the small test code and someone would probably have suggestions.

Until you post what you have and what error(s) are presented - or what does not work as you want, it will be difficult for someone to offer specifics.
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
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts Is it possible to pass variables of s... Csongor CLIST & REXX 2 Fri Jun 10, 2016 7:33 pm
No new posts how to pass data from a rexx program ... Akshay Yadav TSO/ISPF 8 Mon Feb 15, 2016 12:05 pm
No new posts How to pass a structure to external p... Pedro PL/I & Assembler 8 Tue Jan 19, 2016 7:05 am


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