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

  1. Program CheckIt;
  2.  
  3. Uses
  4.   CRT,
  5.   DOS,
  6.   FileLock;
  7.  
  8. Var
  9.   f : File of Integer;
  10.   i : integer;
  11.   oldExit : Pointer;
  12.  
  13. {$F+}
  14. Procedure MyExit;
  15. {$F-}
  16. Begin
  17.   ExitProc := oldExit;
  18.   Seek ( f, 0 );
  19.   While not EOF ( f ) Do
  20.   Begin
  21.     if Unlock ( f, FilePos ( f ), 1 ) Then ;
  22.     Read ( f, i );
  23.   End;
  24.   Close ( f );
  25. End;
  26.  
  27. Begin
  28.   oldExit := ExitProc;
  29.   ExitProc := @MyExit;
  30.  
  31.   Assign ( f, 'f:\data.dat' );
  32.   FileMode := 66;
  33.   Reset ( f );
  34.   Repeat
  35.     For i := 1 to 10 do
  36.     Begin
  37.       If ( not Lock ( f, i, 1 ) ) Then
  38.       Begin
  39.         GotoXY ( 1, i );
  40.         WriteLn ( i, ' is locked.' )
  41.       End
  42.       Else
  43.       Begin
  44.         GotoXY ( 1, i );
  45.         WriteLn ( '                     ' );
  46.         Repeat Until Unlock ( f, i, 1 );
  47.       End
  48.     End;
  49.   Until KeyPressed;
  50. End.
  51.