Sign in Join
FPDoc Onlineexperiment

Erase procedure

In unit System

Delete a file from disk.

Declaration

pascal
procedure Erase(var f: File)

Description

Erase removes an unopened file from disk. The file should be assigned with Assign, but not opened with Reset or Rewrite

Errors

Depending on the state of the {$I} switch, a runtime error can be generated if there is an error. In the {$I-} state, use IOResult to check for errors.

See also

Example: ex20

pascal
Program Example20;

{ Program to demonstrate the Erase function. }

Var F : Text;

begin
  { Create a file with a line of text in it}
  Assign (F,'test.txt');
  Rewrite (F);
  Writeln (F,'Try and find this when I''m finished !');
  close (f);
  { Now remove the file }
  Erase (f);
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.