
- Neil Young
Compiler I/O Methods
| CompilerOpenFile() | Opens specified text file for processing during compile-time logic and returns a file Id |
| CompilerReadFile() | Reads the next record from the text file specified by the file Id |
| CompilerWriteFile() | Writes a record to the text file specified by the file Id |
| CompilerFileError() | Returns the error Id associated with the last compile-time I/O operation |
| CompilerEndOfFile() | Returns true if the end-of-file flag is set for the specified text file |
| CompilerCloseFile() | Closes the specified text file |
See Also
Primitive Framework, Compiler System Methods, Compiler Dialog Methods
public method<int> compiler CompilerOpenFile(string FileName, bool WriteFlag = false, bool AppendFlag = false)
Parameters
FileName
Full file name to be opened
WriteFlag
Flag to specify whether write operations are permitted
AppendFlag
Flag to specify whether data will be appended
Return Value
A positive integer Id to uniquely identify this open text file
Description
This compiler method attempts to open the specified text file for compile-time I/O logic and returns a unique file Id (positive integer) if successful. A value of zero will be returned if not successful. The AppendFlag only applies if the WriteFlag is true. If AppendFlag is true, the first write operation occurs at the end of the file. If false, the data is truncated and the first write operation occurs at the beginning of the file.
If the WriteFlag is true, the File I/O efffectively operates in a "StreamIO.Read" mode, and if WriteFlag is false, it operates in a "StreamIO.Write" mode. Compiler file I/O does not support a Read/Write mode.
Compiler Method
public method<string> compiler CompilerReadFile(int FileId, bool PeekOnly = false)
Parameters
FileId
Valid internal file Id
PeekOnly
Don't move internal file pointer if true
Return Value
Text string representing next record from file
Description
This compiler method reads the next record from the specified file and returns it. If the "end of file" flag is already set, or if an I/O error occurs, and empty string is returned. The FileId must be a valid file identifier returned from a previous call to CompilerOpenFile(). Once a successful read operation is performed, the internal file pointer is advanced to the next record.
Compiler Method
public method<int> compiler CompilerWriteFile(int FileId, string Record, bool UseCR = true)
Parameters
FileId
Valid internal file Id
Record
Text string to be written to the file to create a new record
UseCR
Write a CR character before the LF if true
Return Value
Zero if success and non-zero if an error
Description
This compiler method writes the specified record to the specified file. It returns zero if successful and a non-zero error indicator if not successful. The FileId must be a valid file identifier returned from a previous call to CompilerOpenFile(). Once a successful write operation is performed, the internal file pointer is advanced to the end of the record just written.
The text of the string is written to the file, followed by either a LF character or a CR/LF combination based on the UseCR flag.
Compiler Method
public method<int> compiler CompilerFileError(int FileId)
Parameters
FileId
Valid internal file Id
Return Value
Error return value from previous I/O operation
Description
This compiler method returns the error Id associated with the last file I/O operation which occurred for this File Id.
Compiler Method
public method<bool> compiler CompilerEndOfFile(int FileId)
Parameters
FileId
Valid internal file Id
Return Value
Value of end-of-file flag
Description
This compiler method returns true if internal file pointer for the specified file is at the end-of-file position, and false if not. If end-of-file is true, a read operation will return an empty string.
Compiler Method
public method<int> compiler CompilerCloseFile(int FileId)
Parameters
FileId
Valid internal file Id
Return Value
Zero if success and non-zero if an error
Description
This compiler method closes the specified file and flushes all buffered data to the file if it was opened for writing. The FileId must be a valid file identifier returned from a previous call to CompilerOpenFile(). The File Id is no longer valid once the file is closed.
Compiler Method