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

How to print out only array member with value ?


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

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Wed Jun 18, 2014 7:15 pm
Reply with quote

Hi ,

I got the following code , i want to get the output only show the array member that got value , i don't want to get like A.2 and A.4...

Anything wrong with the code ?
Thanks for you help!

/* REXX */
A.0=1
A.1=2
A.3=4
A.5=2
DO L=0 TO 5
IF A.L\='' THEN
SAY A.L
END

Output :

1
2
A.2
4
A.4
2
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jun 18, 2014 7:29 pm
Reply with quote

why not initialize the value in order?

What is the purpose and scenario you need to do this way ?

And also it is not a good way to initialise A.0

Normally the conventions followed are that

anything.0 = store the size
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Wed Jun 18, 2014 7:37 pm
Reply with quote

Thank you for your reply.

I am writing the rexx to general the JCL , this JCL is used to copy member from one data set to another. First setp is to get the member name form input and then use the loop to assign the value(member name) to array then print the member name. So i don't want to print the array member with no value , like A.2
...

I don't know what wrong with this progrom?
my actual progrom output is :

COPY OUTDD=OUT0,INDD=((INP0,R))
BA.1
BA.2
[color=red]BA.3 ----> i dont' want to see this

BA.4 [/color]
SELECT MEMBER=(CIMVADUD)
SELECT MEMBER=(CIMVDDIO)
SELECT MEMBER=(CIMVIMAS)
SELECT MEMBER=(CIMVIMBA)
SELECT MEMBER=(CIMVLUMP)
SELECT MEMBER=(CIMVREXX)
SELECT MEMBER=(CIMVUSUP)
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jun 18, 2014 7:42 pm
Reply with quote

Could post the actual code with code tag?
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Wed Jun 18, 2014 7:46 pm
Reply with quote

I want to post the acutal code but code is long and if you look might be confusing , because this code also does something else. But the basic idea is simple as that small progrom. so i just wnat to know how to make that small progrom works ....
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jun 18, 2014 7:49 pm
Reply with quote

Ok so to put a question to you

In what case do you get

Code:
BA.1
BA.2
BA.3


??

Instead of resolved values
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Wed Jun 18, 2014 8:04 pm
Reply with quote

Yes. My rexx will select the member according to different condtion . for example. i have total 10 member name in PDS. I only select 5 out of 10. So when i print out the array , there are some memeber in array have no value .so i will get somehing like
BA.1
BA.2
BA.3

I don't know if i make it clear..
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Jun 18, 2014 8:09 pm
Reply with quote

Initialize your array (stem really but that is for another time) before you start:
BA. = ''

Do not use the 0 position for actual data.
It is for holding the count of the other positions.
It is optional.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jun 18, 2014 8:13 pm
Reply with quote

Do not increment the stem everytime

Increment only when u pass some value

So when you write you won't have any problem
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Wed Jun 18, 2014 8:20 pm
Reply with quote

to davaporcelan. I initialized the BA.='' , i works perfectly .... thank you for your help!!

to Pandora-Box, thanks for your help. i will check it
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 18, 2014 8:20 pm
Reply with quote

what you want is to determine if the variable has or has not been initialized.
look at the guidline here

and ignore the responses that did not answer your question. they are work-arounds. learn the language.
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Wed Jun 18, 2014 8:22 pm
Reply with quote

To dbzTHEdinosauer, thanks for your suggestion , the problem is i didn't initialized the array
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jun 23, 2014 8:16 pm
Reply with quote

1. sorry, the suggestion should have been to read about symbol. at the bottom of this post is some code to explain.

an as an added suggestion,
i would always use the routine. you get in the habit of assuming things are initialized, and sometimes they are not. especially is you are writting functions or called routines that others can call.

another thing that will enable you to get thru the manual, easier than you
can now,
classic rexx (that is the old stuff before OORexx) does not have array(s), only stems........so when you search in the manual for 'array', you will not find anything (except 'stems not array')

same with mf cobol.

Code:

j.0 = 'jay.zero'
j.1 = '121'
j.3 = '123'
j.5 = j.0
do i = 1 to 5
  if symbol('j.i') = 'VAR' then say  j.i
   else say 'j.'i 'is: ' symbol('j.i')

end

output:
121
j.2 is:  LIT
123
j.4 is:  LIT
jay.zero
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Tue Jun 24, 2014 12:22 am
Reply with quote

Hi
dbzTHEdinosauer

I tried symbols ,it works perfect !!! thanks
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 JCL sortcard to print only the records DFSORT/ICETOOL 11
No new posts How to copy the -1 version of a membe... TSO/ISPF 4
No new posts Searching for a member but don't know... TSO/ISPF 6
No new posts Looking For a PDS Member Without Open... PL/I & Assembler 10
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
Search our Forums:

Back to Top