next up previous contents index
Next: Upcase Up: Functions and Procedures Previous: Trunc

Truncate

   

Declaration:

Procedure Truncate (Var F : file) ;

Description:

Truncate truncates the (opened) file F at the current file position.

Errors:

Errors are reported by IOresult.

See also:

Append, Filepos, Seek

Example
Program Example71;

{ Program to demonstrate the Truncate function. }

Var F : File of longint;
    I,L : Longint;
    
begin
  Assign (F,'test.dat');
  Rewrite (F);
  For I:=1 to 10 Do 
    Write (F,I);
  Writeln ('Filesize before Truncate : ',FileSize(F));
  Close (f);
  Reset (F);
  Repeat
    Read (F,I);
  Until i=5;
  Truncate (F);
  Writeln ('Filesize after Truncate  : ',Filesize(F));
  Close (f);
end.



Michael Van Canneyt
Thu Sep 10 14:02:43 CEST 1998