Opens a specified file.
Category: | External File |
Returned data type: | Integer |
Note: | The returned value is a Boolean value where 1= success and 0 = error. |
fileobject.open(<filename, openmode>)
filename
a string representing the name of the file to be opened. If the file does not exist, it will be created. This parameter can be specified as a fixed string, field name, or expression
openmode
a string representing the openmode to be used. This can be specified as a fixed string, field name, or expression [a = append, r = read, w = write, rw = read and write]
The OPEN method opens the file that is provided in the filename parameter. If the file does not exist and an openmode is specified containing either an "a" or "w" then the file will be created. If the openmode is not specified a value of false will be returned.
When writebytes and writeline methods write at the end of the file, unless seekbegin, seekcurrent, or seekend methods are used to adjust the position in the file. In that case the information is written at the current position in the file.
If an openmode of "w" is used, the writebytes and writeline methods write at the current position in the file and potentially overwrite existing information in the file.
file myfile
if ( myfile.open("data.txt") ) then ...