help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



[Overview][Constants][Types][Classes][Procedures and functions][Variables] Reference for unit 'System' (#rtl)

Close

Close a file

Declaration

Source position: line 0

procedure Close(

  var f: file

);

procedure Close(

  var t: Text

);

Description

Close flushes the buffer of the file F and closes F. After a call to Close, data can no longer be read from or written to F. To reopen a file closed with Close, it isn't necessary to assign the file again. A call to Reset or Rewrite is sufficient.

Errors

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

See also

Assign

  

Assign a name to a file

Reset

  

Open file for reading

Rewrite

  

Open file for writing

Flush

  

Write file buffers to disk

Example

Program Example9;

{ Program to demonstrate the Close function. }

Var F : text;

begin
 Assign (f,'Test.txt');
 ReWrite (F);
 Writeln (F,'Some text written to Test.txt');
 close (f); { Flushes contents of buffer to disk,
              closes the file. Omitting this may
              cause data NOT to be written to disk.}
end.

Notes

 No notes exist for this page yet. 





lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505