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

Will this code extract 1 byte from file using rexx?


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

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sat Nov 10, 2018 11:13 pm
Reply with quote

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
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Sun Nov 11, 2018 12:15 am
Reply with quote

What happened when you ran it?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Sun Nov 11, 2018 3:05 am
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Sun Nov 11, 2018 5:50 am
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Sun Nov 11, 2018 5:58 am
Reply with quote

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
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sun Nov 11, 2018 7:13 am
Reply with quote

Enrico is right. Need to extract 1byte from each record.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sun Nov 11, 2018 1:38 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Sun Nov 11, 2018 3:31 pm
Reply with quote

no reformatting will make a bad snippet good icon_cool.gif
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sun Nov 11, 2018 8:00 pm
Reply with quote

Quote:
no reformatting will make a bad snippet good

True - but it makes it easier to see how bad it is.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top