Provides an interface for file input/output. FileOpen returns an object of this type.
Reads a string of characters from the file and advances the file pointer.
String := File.Read([Characters])
Characters | The maximum number of characters to read. If omitted, the rest of the file is read and returned as one string. |
Returns | A string. |
Writes a string of characters to the file and advances the file pointer.
File.Write(String)
String | A string. |
Returns | The number of bytes (not characters) that were written. |
Reads a line of text from the file and advances the file pointer.
Line := File.ReadLine()
Returns | A line of text. This may include `n , `r`n or `r depending on the file and EOL flags used to open the file. |
Writes a string of characters followed by `n
or `r`n
depending on the flags used to open the file. Advances the file pointer.
File.WriteLine([String])
String | An optional string. |
Returns | The number of bytes (not characters) that were written. |
Reads a number from the file and advances the file pointer.
Num := File.ReadNumType()
NumType | One of the following specified directly as part of the function name: UInt, Int, Int64, Short, UShort, Char, UChar, Double, or Float. |
Returns | A number if successful, otherwise an empty string. |
Writes a number to the file and advances the file pointer.
File.WriteNumType(Num)
NumType | One of the following specified directly as part of the function name: UInt, Int, Int64, Short, UShort, Char, UChar, Double, or Float. |
Num | A number. |
Returns | The number of bytes that were written. For instance, WriteUInt returns 4 if successful. |
Read raw binary data from the file into memory. If a var is specified, it is expanded automatically when necessary.
File.RawRead(VarOrAddress, Bytes)
VarOrAddress | A variable or memory address to which the data will be copied. Usage is similar to NumGet. |
Bytes | The maximum number of bytes to read. |
Returns | The number of bytes that were read. |
Write raw binary data to the file.
File.RawWrite(VarOrAddress, Bytes)
VarOrAddress | A variable containing the data or the address of the data in memory. Usage is similar to NumPut. |
Bytes | The number of bytes to write. |
Returns | The number of bytes that were written. |
Moves the file pointer.
File.Seek(Distance [, Origin = 0]) File.Position := Distance File.Pos := Distance
Distance | Distance to move, in bytes. Lower values are closer to the beginning of the file. |
Origin | Starting point for the file pointer move. Must be one of the following:
|
Returns | A non-zero value if successful, otherwise zero. |
Pos := File.Tell() Pos := File.Position Pos := File.Pos
Returns | The current position of the file pointer, where 0 is the beginning of the file. |
Retrieves or sets the size of the file.
FileSize := File.Length File.Length := NewSize
NewSize | The new size of the file, in bytes. |
Returns | The size of the file, in bytes. |
IsAtEOF := File.AtEOF
Returns | A non-zero value if the file pointer has reached the end of the file, otherwise zero. |
Closes the file, flushes any data in the cache to disk and releases the share locks. Although the file is closed automatically when the object is freed, it is recommended to close the file as soon as possible.
File.Close()
No parameters or return value.
Retrieves or sets the text encoding used by this file object.
Encoding := File.Encoding File.Encoding := Encoding
Encoding | A string in the format accepted by FileEncoding. |