home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST1401.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-11-17  |  1.6 KB  |  44 lines

  1. Program BurnIn;
  2.  
  3. Type
  4.   String10 = String [10];
  5.   BurnType = Record
  6.                ID    : String10;
  7.                MyVal : Real;
  8.              End;
  9.  
  10. Const
  11.   MyBurnIn : BurnType = ( ID:'MyUniqueID'; MyVal:3.1415926 );
  12.  
  13. Var
  14.   c : LongInt;
  15.   f : File;
  16.   s : String10;
  17.  
  18. Begin
  19.  
  20.   WriteLn ( 'ID is currently    = ',MyBurnIn.ID );
  21.   WriteLn ( 'MyVal is currently = ',MyBurnIn.MyVal );
  22.   MyBurnIn.MyVal := MyBurnIn.MyVal + 1;
  23.   WriteLn ( 'Next time, MyVal   = ',MyBurnIn.MyVal );
  24.  
  25.   Assign ( f, ParamStr ( 0 ) );  { Set file variable = to program that is }
  26.   Reset ( f, 1 );                { currently running. Set buffer size = 1 }
  27.   c := FileSize ( f );           { Get current size of the file }
  28.   c := c - SizeOf ( s );         { Set size to  size - string length }
  29.   s := '';                       { Initialize the search string }
  30.   While ( c > 0 ) and ( s <> MyBurnIn.ID ) Do
  31.   Begin         { Loop until we reach the start of the file, or a match is }
  32.                 { found.                                                   }
  33.     Seek ( f, c );                    { Move file pointer to new location }
  34.     BlockRead ( f, s, SizeOf ( s ) ); { Block read into the search string }
  35.     Dec ( c );                        { Decrement the counter by 1 position }
  36.   End;
  37.   If ( c > 0 ) Then           { If we did find the string, do the following }
  38.   Begin
  39.     Seek ( f, c + 1 );        { Seek to the offset of the found string }
  40.     BlockWrite ( f, MyBurnIn, SizeOf ( MyBurnIn ) ); { Write the new record }
  41.   End;
  42.   Close ( f );                { Close the file }
  43. End.
  44.