Opens a file on the host system.
hFile = FileOpen(sPath, fmMode[, fsShare[, ftType]])
|hFile||A handle to the opened file. HFILE.|
|sPath||The name of the file to open. STRING.|
|fmMode||The mode to open the file with. FILEMODE.|
|fsShare||Optional: Specifies file-sharing behavior. FILESHARE.|
|ftType||Optional: Specifies the format of the text file to be created. Only has an affect when creating a new file. FILETYPE.|
FileOpen opens or creates the file that is identified by sPath, depending on the specified mode. The function returns a file handle of type HFILE, which you can pass to other file functions.
Any open local files are automatically closed and saved at the end of a test script.
The file manipulation functions that control writing to a file, for example FileWriteLine and FileWriteValue, do not test your accessibility to a file. This means that you cannot write information to a file that has been opened in read only mode with FileOpen. The function will successfully return, but no information is actually written to the file. There is no error message that indicates this.
FileOpen is not designed for remote access.
The following code sample checks a BOOLEAN value presumably passed into the function or test case to determine whether or not the file should be shared and then sets the file-sharing behavior accordingly:
[ ] // output file handle [ ] HFILE OutputFileHandle [ ] FILESHARE fShare [ ] [ ] // check to see if file opening should lock out other writers [ ] if (bExclusiveWrite == TRUE) [ ] fShare = FS_DENY_WRITE [ ] else [ ] fShare = FS_DENY_NONE [ ] [ ] // now open the file [ ] OutputFileHandle = FileOpen("mydata.txt", FM_WRITE, fShare)