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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seek problem and very very long string!!!! 1

Status
Not open for further replies.

fatlardo

Programmer
May 7, 2007
41
GB
I am trying to get data from a file which can be anywhere in the file. It works by reading in a block of data at a time and finding the position of the identifier of the required data within that block. The identifier is 'TAG'.
The problem comes when the identifier is in the first block read in. It will miss off the first character (byte) every time, causing data to end up in the wrong variables.

THe code I am using is:

Seek(F, PosEx('TAG', readin16) - 1)
BlockRead(F, tagheader, 10);

I have tried changing the -1 to many different numbers, but I can never get the first byte to be read!

HELP!!!!!!

Gary
 
Assign(F, filename);
Reset(F, 1);

Where filename is a parameter passed to the function.

Gary
 
(again knowing how these things are defined will help - a good illustration of how such little information can get provided in some of these posts).

If you're working with character blocks, you need to realize what the types are that you are working with.

If tagheader is defined as "string", it might be that it's taking the first byte and assuming it as the length byte. If that's the case, try it with an array of characters.
 
You know what, thats so simple it might work!! Thanks and yes, it was a string!

I really should watch what types I use in future.

Thanks a lot

Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top