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

  1. Program Pseudo;
  2.  
  3. Uses
  4.   FileLock;
  5.  
  6. Type
  7.   RecType = ...
  8.   FileType = File of RecType;
  9.  
  10. Var
  11.   r       : RecType;
  12.   f       : FileType;
  13.   rn      : LongInt;
  14.   oldExit : Pointer
  15.  
  16. {$F+}
  17. Procedure MyExit;
  18. {$F-}
  19. Begin
  20.   ExitProc := oldExit;
  21.   Seek ( f, 0 );
  22.   While not EOF ( f ) Do
  23.   Begin
  24.     if Unlock ( f, FilePos ( f ) ) Then ;
  25.     Read ( f, r );
  26.   End;
  27.   Close ( f );
  28. End;
  29.  
  30. Begin
  31.   oldExit := ExitProc;
  32.   ExitProc := @MyExit;
  33.  
  34.   Assign ( f, 'filename' );
  35.   FileMode := 66;
  36.   Reset ( f );
  37.   Repeat
  38.     rn := GetRecordNumber;
  39.     Repeat Until Lock ( f, rn );
  40.     Seek ( f, rn-1 );
  41.     Read ( f, r );
  42.     EditRecord ( r );
  43.     Write ( f, r );
  44.     Repeat Until UnLock ( f, rn );
  45.   Until Done;
  46.   Close ( f );
  47. End.
  48.