Hello,
I'll try something like
If filesize(drawfile)>0 then
Seek(drawfile, sizeof(drawfile)-1)
else
"empty file";
For portability of you file and software, I recommand you to use a "packed record" with an internal
forced word-align of the double data. If size matters, no need to align.
Type
DrawCMD = Record
GC: Byte;
______: byte; { no use axcept to force align on words for
speed on certain systems }
PX,PY,PZ,GX,GY,GZ,GI,GJ,R,SA,EA:Double;
End;
This can also be uses for memory access, as on some processors, word aligning data can save some cpu
cycles with reference to non aligned data for data longer than one byte/char.
Chers, Ched
Le 09.07.2017 à 13:45, James Richters a écrit :
I have a few questions about fixed record files. I have the following:
Type
DrawCMD = Record
GC: Byte;
PX,PY,PZ,GX,GY,GZ,GI,GJ,R,SA,EA:Double;
End;
Var
DrawFile : File Of DrawCMD;
Drawinfo : DrawCMD;
I wish to get to the end of the file and read the last record. Currently I am
doing it like this:
Reset(DrawFile);
while not eof(DrawFile) do
begin
Read(DrawFile,DrawInfo);
End;
When this finishes Drawinfo contains the last record of the file. But I’m wondering if there is a better
way since it’s a file of fixed records.
I’m also wondering if there is a way to insert a record at the beginning of the file, or in the middle of
the file without doing something like copying the entire file to a temp file, then re-writing the entire
new file in the desired order?
James
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal