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 Stem(array) to calling program

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

New User


Joined: 22 Sep 2013
Posts: 81
Location: pune india

PostPosted: Thu Aug 07, 2014 9:56 am    Post subject: Passing Stem(array) to calling program
Reply with quote

Hi All

I am trying to pass all array elements to calling program from subprograme using retun statement.

My Stem elements are like below
Element.1
Element.2
Element.3
No of array element could be anything varying from 1 to n.

But when is use "Say result" in caling programe i am unable to dispplay the values of stem variable.
Back to top
View user's profile Send private message

Paul Voyner

New User


Joined: 26 Nov 2012
Posts: 51
Location: Switz

PostPosted: Thu Aug 07, 2014 11:49 am    Post subject:
Reply with quote

If your subprogram is a different rexx in a different member, that won't work, can't work. RESULT is a single variable, never a stem.
If the array isn't too big, pass it back in result as a long string and then parse it in the calling program.
Back to top
View user's profile Send private message
trushant.w

New User


Joined: 22 Sep 2013
Posts: 81
Location: pune india

PostPosted: Thu Aug 07, 2014 12:03 pm    Post subject:
Reply with quote

Hi Paul

Thanks for reply!!!

But how can i create a single concatenated string consisting of n elements of array/stem because here i cannot use concate operator (||) as no of elements in array can vary.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Aug 07, 2014 12:17 pm    Post subject:
Reply with quote

try this
Code:
PAS_STRING = ELEMENT.1

DO I=2 TO ELEMENT.0
    PAS_STRING = PAS_STRING || '~' || ELEMENT.I
END
Back to top
View user's profile Send private message
trushant.w

New User


Joined: 22 Sep 2013
Posts: 81
Location: pune india

PostPosted: Thu Aug 07, 2014 1:02 pm    Post subject:
Reply with quote

Hi mistah,

This is working perfectly.

Thanks Mistah and Paul
Back to top
View user's profile Send private message
Paul Voyner

New User


Joined: 26 Nov 2012
Posts: 51
Location: Switz

PostPosted: Thu Aug 07, 2014 1:06 pm    Post subject:
Reply with quote

You're welcome !
Maybe you've done this already, but this will parse the returned string
Code:
/*rexx*/
trace R
string = "a a a a~bb bb bb~c c ~d"
l = length(string)
i = 1
do while l > 0
  p = pos('~',string)
  stem.i = left(string,p-1)
  string = right(string,l-p)
  l = length(string)
  i = i + 1
end
exit
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Aug 07, 2014 6:11 pm    Post subject: Reply to: Passing Stem(array) to calling program
Reply with quote

and why not ...
Code:
string = "a a a a~bb bb bb~c c ~d"
do i = 1 while ( string \= "")
    parse var string stem.i "~" string
end
stem.0 = i - 1
do i = 1 to stem.0
    say i stem.i
end
Back to top
View user's profile Send private message
Steve Coalbran

New User


Joined: 01 Feb 2007
Posts: 85
Location: Stockholm, Sweden

PostPosted: Mon Aug 25, 2014 7:36 pm    Post subject:
Reply with quote

Try this. It was actually written as an educational snippet...
Code:
/**REXX*(RXCALLER)*/TRACE "O"                                         
RC = BPXWDYN("ALLOC RTDDN(TDD) RTDSN(TDS) NEW REUSE UNIT(VIO)")       
IF( RC<>0 )THEN EXIT 69                                               
twister = "Peter Piper  picked a peck of pickled peppers.",           
         "§A peck of pickled peppers  Peter Piper  picked.",           
         "§If Peter Piper  picked a peck of pickled peppers,",         
         "§How many pickled peppers  did Peter Piper pick?"           
yourstem.0 = WORDS(twister)                                           
l = 1                                                                 
DO w = 1 TO yourstem.0                                                 
   yourstem.w=WORD(twister,w)                                         
   IF( LEFT(yourstem.w,1)="§" )THEN l = l+1                           
END                                                                   
SAY w "words in" l "lines."                                           
"EXECIO" yourstem.0 "DISKW" tdd "(STEM yourstem. FINIS "               
CALL RXCALLED tdd                                                     
EXIT /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
                                                                       
/**REXX*(RXCALLED)*/ TRACE "O"                                         
ARG tdd                                                               
"EXECIO * DISKR" tdd "(STEM yourstem. FINIS "                         
line = ""                                                             
line. = 0                                                             
eop = yourstem.0+1                                                     
yourstem.eop = "§"                                                     
DO w = 1 TO eop                                                       
   twd = STRIP(yourstem.w)                                             
   IF( LEFT(twd,1)="§" )THEN DO                                       
      IF( LEFT(line,1)="§" )THEN                                       
         line = SUBSTR(line,2)                                         
      ELSE NOP                                                         
      PARSE VALUE line.0+1 line";",                                   
             WITH t line.t ";" line 1 line.0 .                         
      END                                                             
   ELSE NOP                                                           
   line = line||twd" "                                                 
END                                                                   
"EXECIO" line.0 "DISKW" tdd "(STEM line. FINIS "                       
ADDRESS ISPEXEC "LMINIT DATAID(V) DDNAME("tdd") "                     
ADDRESS ISPEXEC "VIEW   DATAID(&V) "                                   
ADDRESS ISPEXEC "LMFREE DATAID(&V) "                                   
"FREE DD("tdd") "                                                     
EXIT /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

I'm sure you can cut the tonge-twister processing out? icon_wink.gif
Back to top
View user's profile Send private message
Steve Coalbran

New User


Joined: 01 Feb 2007
Posts: 85
Location: Stockholm, Sweden

PostPosted: Tue Aug 26, 2014 10:11 am    Post subject: Passing Stem(array) to calling program
Reply with quote

Simplified...

Code:
/**REXX*(RZCALLER)*/TRACE "R"                                         
RC = BPXWDYN("ALLOC RTDDN(TDD) RTDSN(TDS) NEW REUSE UNIT(VIO)")       
IF( RC<>0 )THEN EXIT 69                                               
stem.1 = "A"                                                           
stem.2 = "B"                                                           
stem.3 = "C"                                                           
stem.4 = "D"                                                           
stem.5 = "E"                                                           
stem.6 = "F"                                                           
stem.0 = "6"                                                           
"EXECIO" stem.0 "DISKW" tdd "(STEM stem. FINIS "                       
CALL RZCALLED tdd                                                     
EXIT /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

Code:
/**REXX*(RZCALLED)*/ TRACE "O"                                         
ARG tdd                                                               
"EXECIO * DISKR" tdd "(STEM stem. FINIS "                             
DO i = 1 TO stem.0                                                     
   SAY stem.i                                                         
END                                                                   
EXIT /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

icon_smile.gif
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Wed Aug 27, 2014 4:09 am    Post subject: Re: Reply to: Passing Stem(array) to calling program
Reply with quote

enrico-sorichetti wrote:
and why not ...
Code:
string = "a a a a~bb bb bb~c c ~d"
do i = 1 while ( string \= "")
    parse var string stem.i "~" string
end
stem.0 = i - 1
do i = 1 to stem.0
    say i stem.i
end


Code:

st.0 = 0
do while string \= ''
  parse value st.0+1 string with ? st.? string 1 st.0 .
end
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Wed Aug 27, 2014 2:13 pm    Post subject: Re: Reply to: Passing Stem(array) to calling program
Reply with quote

prino wrote:
Code:

st.0 = 0
do while string \= ''
  parse value st.0+1 string with ? st.? string 1 st.0 .
end
OoOooh! Now that's interesting...
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Aug 27, 2014 10:34 pm    Post subject: Reply to: Passing Stem(array) to calling program
Reply with quote

Code:

#!/usr/bin/rexx

say "original snippet"
string = "a a a a~bb bb bb~c c~d"
do i = 1 while ( string \= "")
    parse var string st.i "~" string
end
st.0 = i - 1
do i = 1 to st.0
    say i st.i
end
drop st.

say "prino unmodified snippet, it will return words!"
string = "a a a a~bb bb bb~c c~d"
st.0 = 0
do while string \= ''
  parse value st.0+1 string with ? st.? string 1 st.0 .
end
do i = 1 to st.0
    say i st.i
end
drop st.


say "prino snippet, modified to return THE <strings> separated by ~"
string = "a a a a~bb bb bb~c c~d"
st.0 = 0
do while string \= ''
  parse value st.0+1 string with ? st.? "~" string 1 st.0 .
end
do i = 1 to st.0
    say i st.i
end
drop st.


Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Wed Aug 27, 2014 10:43 pm    Post subject:
Reply with quote

Obviously missed that one. icon_redface.gif icon_redface.gif icon_redface.gif
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Thu Aug 28, 2014 1:56 am    Post subject:
Reply with quote

do I = 1 to element.0
queue element.I
end

call sub-routine

sub-routine
element.0 = queued()

do I = 1 to element.0
pull element.I
end
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 I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 2 Tue Dec 06, 2016 8:30 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm
No new posts A sample of exit program for exit XMN... lind sh CICS 2 Mon Oct 03, 2016 5:07 pm
No new posts Need points to tune IMS Checkpoint Pr... satish.ms10 IMS DB/DC 2 Fri Sep 30, 2016 4:12 pm


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