View previous topic :: View next topic
|
Author |
Message |
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
Dear all
Please validate whether the below piece of code will extract 1 byte f rtom file using rexx
Code: |
"EXECIO * DISKR MYINDD (FINIS STEM MYVAR"
DO i = 1 to MYVAR0
this_line = VALUE('MYVAR'||i)
END"
Do i = 1 to myvar.n /* to get the record */
If i< myvar.n then
Do
Do j = 1 to 500
X=substr(myvar.n,1,i) /* to get the 1 byte of record*/
End
End
End
|
code reformatted to give decent indentation |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
What happened when you ran it? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
the code snippet You posted does not make any sense
try with
Code: |
"EXECIO * DISKR MYINDD (FINIS STEM MYVAR."
pos = 1
do i = 1 to myvar.0
say "line" i ", pos" pos "'"substr(myvar.i,pos,1)"'"
end
|
|
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2010 Location: USA
|
|
|
|
In order to extract one byte, there is absolutely no need to read all records. Especially when file size can be 100,000,000 records. Especially doing this senseless activity in one shot, into single stem (in the memory!!!) |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
from the number of do statements it seemed clear that the TS wanted to extract 1 byte from each record...
I am really tired of talking about good practices, when most people do not care about them.
if I feel in the mood I provide some hints, otherwise I just ignore the topic |
|
Back to top |
|
|
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
Enrico is right. Need to extract 1byte from each record. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Why do you need someone to verify it your code? Why can you not do it yourself? A simple test data set (not file) with one record and LRECL of 10, for example, would show if your code worked or not.
How many records in your input data set? And LRECL? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
no reformatting will make a bad snippet good |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Quote: |
no reformatting will make a bad snippet good |
True - but it makes it easier to see how bad it is. |
|
Back to top |
|
|
|