View previous topic :: View next topic
|
Author |
Message |
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
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 |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Could post the actual code with code tag? |
|
Back to top |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Ok so to put a question to you
In what case do you get
??
Instead of resolved values |
|
Back to top |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
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 |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
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 |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
To dbzTHEdinosauer, thanks for your suggestion , the problem is i didn't initialized the array |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
Hi
dbzTHEdinosauer
I tried symbols ,it works perfect !!! thanks |
|
Back to top |
|
|
|