TextFileOpen |
Top Previous Next |
Prototype
IntFileHandle:=TextFileOpen (FileName,Bool)
Description
Opens a text file and returns the handle.
Parameters
FileName : A string containing a valid path and filename.
Bool: logical value true or false. If it is true the access to the file it happens in writing, otherwise in reading
Returned value
IntFileHandle: integer value that corresponds at the handle of the file.
Notes
The returned handle can be used as parameter in the functions that operate on the files (TextFileClose, TextFileRead, TextFileWrite, …).
Example
// Delete output file, if exists DeleteFile('c:\text\output.txt');
// Create a new output empty file CreateFile('c:\text\output.txt');
// Open output file for text writing OutFile:=TextFileOpen('c:\text\output.txt',true);
// Open input file for text reading InFile:=TextFileOpen('c:\text\output.txt',false);
// Repeat until is at end of input file While not TextFileEOF(InFile) do Begin Line:=TextFileReadln(inFile); TextFileWriteln(outFile,Line); End;
// Close the input file TextFileClose(inFile);
// Close the output file TextFileClose(outFile);
|