Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSeek/FileRead?????

Status
Not open for further replies.

kaul125

Programmer
Jan 29, 2002
87
US
When I open a file with FileOpen() in PB6.5 I want to read the last record.

FileSeek() has a few parameters that allows for you to start at the end of the file(FromEnd!) and then read back some many characters. However since I don't know how long the last record is, I won't be able to use the FileSeek(), Correct?

Without using the FileRead() until I hit the last record, How can I read just the last record using the FileRead() without looping through every record?

Keith
 
hi!
I'd prefer know the long for each register..but if you don't have it, you could do the following:

Save a Register Header before your data

struct {
long size;
...
}

with it, you know the real size of your data.
If you want to do it better, you make a File header and save general information as "Las record".

When you open your file, you must read the file header and you will know when is your last record and its long.

:)

If you didn't make the file, i think that you should read each char but it's no a good idea...


if u need something else only write me
regards.










 
This can be another use of freeform datawindow. Assuming your file records have carriage control/line feed at end you can build a freeform datawindow with a single column defined in the detail band and use ImportFile to load your file into the dw.

From there, Rowcount() should let you get to the last record regardless of how long individual records are.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top