View previous topic :: View next topic
|
Author |
Message |
Karthick.natesan
New User
Joined: 20 Jan 2012 Posts: 4 Location: India
|
|
|
|
Hi all,
When I try to access record from input file in column wise i find some difficulties.
code is:
Code: |
/*REXX*/
PULL NAME
X. = ' '
"ALLOCATE DSN("NAME") F(INF) SHR"
/**********************************************************************/
/**********************************************************************/
"EXECIO * DISKR INF (STEM INP. FINIS)"
"FREE F(INF)"
STEMLEN = INP.0
COUNT = 1
DO WHILE COUNT <= STEMLEN
X. = INP.COUNT
I = 1
DO WHILE I <= 4
SAY X.I
I = I + 1
END
COUNT = COUNT + 1
END |
input file:
Expected output is
but actual output is
Code: |
aaaa
aaaa
aaaa
aaaa
aaaa
|
can any one hlep me? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Because your code is doing EXACTLY what it is coded to do.
It is your logic that needs addressing and once that has been done, then a recode will be required. |
|
Back to top |
|
|
Karthick.natesan
New User
Joined: 20 Jan 2012 Posts: 4 Location: India
|
|
|
|
hi Expat,
can you help me to get the expected output? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Yes,
Run your code using TRACE I
Watch exactly what is happening and see if you can work it out for yourself. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
If you are wanting columns then you need to interface with DB2. If, however, you are wanting fields then do as expat suggests.
Also, why this...
Code: |
stemlen = inp.0
count = 1
do while cont < stemlen
.
. |
instead of...
Code: |
do count = 1 to inp.0
.
.
|
? |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Learn to use the PARSE instruction. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
You can find the length of the string and make use of SUBSTRING
Code: |
/*REXX*/
STR = 'ABCDE '
LEN = LENGTH(STRIP(STR))
DO I = 1 TO LEN
SAY SUBSTR(STR,I,1)
END |
Experts really would have a better thought too |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Quote: |
When I try to access record from input file in column wise i find some difficulties. |
The problem is that your program has logic for records, but does not have logic for columns. |
|
Back to top |
|
|
|