Read the file from bottom.



IBM's Command List programming language & Restructured Extended Executor

Read the file from bottom.

Postby Viswanathchandru » Tue Jan 01, 2013 11:58 pm

Dear all,

I need clues to read a file from bottom. I tried but I'm struck in this. My code goes like this(Aimed to read the last six records but it didn't obviously it wont)

""EXECIO * DISKR INDD(STEM XEM."
DO IX = XEM.0 TO 6 BY -1 "
.


I'm not able to find how to read the last 6 records of a file. I'm confused to resolve this "DO IX=XEM.0 TO "y" BY -1" I don't know what should be the value of "y". Any suggestions will be helpful.

Regards,
Viswa
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: Read the file from bottom.

 

Re: Read the file from bottom.

Postby Viswanathchandru » Wed Jan 02, 2013 12:58 am

Dear all,

I assume it is not possible to read a file in reverse. googled landed in sort :) finally a way out! Thanks all ..

Wishing you all a very happy and prosperous New year :)

Regards,
Viswa
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: Read the file from bottom.

Postby enrico-sorichetti » Wed Jan 02, 2013 2:51 am

just for the sake of proper logic ...
( very basic math ... after all :mrgreen: )

since You have everything in a stem ( logically equal to an array )
it should not have been that difficult to conclude that
being N the number of elements of the array
the last K entries go from N-K+1 to N

and ...
do i = N to N-K+1 by -1

will process <backwards>

while
do i = N-K+1 to N

will process <forward>

any recent version of <SORT> should support the SUBSET clause
extracting in quite a sophisticated fashion any number of record
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Read the file from bottom.

Postby NicC » Wed Jan 02, 2013 4:07 pm

Just a quick correction on terminology - you do not read a file from the 'bottom' but from the end. ISPF may display a file file from top-to-bottom but you conceptually process a file from start-to-end, left-to-right. Weird? Maybe, but after so many years of looking at diagrams of files in books it is strange to think about proessing top-to-bottom when all the diagrams are left-to-right.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post