info.mailtraq.com > Management > Script Functions A-Z > OpenFile() OpenFile()Opens a text file for reading and returns a handle identifying the file which is valid until released using the CloseFile() function. Each file read operation, using the Read() function, advances a pointer to the next line in the file such that consecutive reads retrieve consecutive lines of text from the opened file. When the end of the opened file is reached, the EOF() function returns true. The same file can be opened for reading by more than one script and more than once in the same script.
handle := OpenFile( path )
- path
- Identifies the file to be opened by its filing system name. If no path is provided, the default location of \database is assumed
- handle
- An integer reference for subsequent references to the open file or nul if the file cannot be opened
Add the contents of the file input.txt to the existing contents, if any, of the file output.txt a := OpenFile("c:\files\input.txt");
b := AppendFile("c:\files\output.txt");
While(Not(EOF(a)),
Write(b, Read(a))
);
CloseFile(a);
CloseFile(b) |