[fpc-pascal] File handling: the TFileStream or the classical way is faster and more efficient?

Michael Van Canneyt michael at freepascal.org
Mon May 25 11:58:09 CEST 2015

On Mon, 25 May 2015, Géza Kovacs Géza wrote:

> Hi!
> Thx your answer.
> Can I use the "AssignFile" procedure from the SysUtils unit instead of
> the simple assign procedure from the System unit?
> What is the problem with the simple "assign"?
> I read from the Free Pascal Wiki:
> AssignFile (prevent the use of the older Assign procedure) - Assign a
> name to a file
> CloseFile (prevent the use of the older Close procedure) - Close opened file
> What is the difference between simple "assign", "close", or
> "AssignFile", and "CloseFile"?

There is none, they are 100% the same.

There is no reason not to use the Assign/Close in non-gui code.

The (IMHO misguided) reason for these statements is that TPersistent and TForm (a TPersistent descendent) 
have Assign and Close methods. Because of this, confusion can arise if you write Assign or Close in TForm methods.


More information about the fpc-pascal mailing list