jmathew
2nd January 2015, 10:53
Hi,
Is there a way in Baan program to read a file in the reverse order which is from the last line and backwards to the first line. Please do let us know the options that are available for this. Thanks.

bhushanchanda
2nd January 2015, 18:34
Hi,

One way I can think of is, use a string array of some max length. Read the file until end of file and keep filling the array with the line read and keep counting the number of rows.

Now, you can use a for/while loop to read the filled array in reverse order.

mark_h
4th January 2015, 23:43
Bhushan gave one good option. Another option is you could create a table and read each row and load it into the table, using an index number. Then do a select with order by descending. Or another way is to look at seq.seek() and see if you can use it. I think maybe if it is a fixed length type file you could use the number of bytes in the row and just keep moving up the file using the from end-of-file mode.

NPRao
6th January 2015, 18:56
If you are on Unix/Linux, you can use the tac command

TAC(1) User Commands TAC(1)

NAME
tac - concatenate and print files in reverse

SYNOPSIS
tac [OPTION]... [FILE]...