[fpc-pascal] Fixed record files

James Richters james at productionautomation.net
Sun Jul 9 15:45:27 CEST 2017


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170709/3f737659/attachment.html>


More information about the fpc-pascal mailing list