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 print out only array member with value ?

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

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Wed Jun 18, 2014 7:15 pm    Post subject: How to print out only array member with value ?
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

Moderator


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

PostPosted: Wed Jun 18, 2014 7:29 pm    Post subject:
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: 106
Location: windsor

PostPosted: Wed Jun 18, 2014 7:37 pm    Post subject: answer
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

Moderator


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

PostPosted: Wed Jun 18, 2014 7:42 pm    Post subject:
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: 106
Location: windsor

PostPosted: Wed Jun 18, 2014 7:46 pm    Post subject: answer
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

Moderator


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

PostPosted: Wed Jun 18, 2014 7:49 pm    Post subject:
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: 106
Location: windsor

PostPosted: Wed Jun 18, 2014 8:04 pm    Post subject: answer
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: 645
Location: Pennsylvania

PostPosted: Wed Jun 18, 2014 8:09 pm    Post subject:
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

Moderator


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

PostPosted: Wed Jun 18, 2014 8:13 pm    Post subject:
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: 106
Location: windsor

PostPosted: Wed Jun 18, 2014 8:20 pm    Post subject: Anser
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    Post subject:
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: 106
Location: windsor

PostPosted: Wed Jun 18, 2014 8:22 pm    Post subject:
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    Post subject:
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: 106
Location: windsor

PostPosted: Tue Jun 24, 2014 12:22 am    Post subject: Reply
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    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 What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 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 File Stauts 92 with member of PDS sandip_mainframe COBOL Programming 4 Fri Jun 10, 2016 12:06 pm
No new posts how to extract the member name ? jackzhang75 CLIST & REXX 1 Wed Feb 17, 2016 9:21 pm
No new posts Check if a member is present in libra... enrico-sorichetti All Other Mainframe Topics 1 Wed Feb 03, 2016 12:29 pm


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