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: 264

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: 869
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

Senior Moderator


Joined: 14 Mar 2007
Posts: 10712
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

Active Member


Joined: 29 Apr 2008
Posts: 924
Location: Maryland

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

Senior Moderator


Joined: 14 Mar 2007
Posts: 10712
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: 264

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: 2448
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

Senior Moderator


Joined: 14 Mar 2007
Posts: 10712
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: 2448
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 Converting a file from PD to display ... SYNCSORT 4
No new posts Execute step regardless of previous s... JCL & VSAM 2
No new posts Record count of RECFM=U tape file DFSORT/ICETOOL 17
No new posts Error 0C1 Reason Code 1 with branch i... PL/I & Assembler 3
No new posts Any examples of calling FTP from REXX? CLIST & REXX 1
Search our Forums:

Back to Top