__openFile
Syntax
__openFile(filename, access)Parameters
filenameThe file to be opened. The filename must include a path, which must either be absolute or use argument variables. For information about argument variables, see Argument variables.
accessThe access type (string).
These are mandatory but mutually exclusive:
"a"append, new data will be appended at the end of the open file"r"read (by default in text mode; combine withbfor binary mode:rb)"w"write (by default in text mode; combine withbfor binary mode:wb)These are optional and mutually exclusive:
"b"binary, opens the file in binary mode"t"ASCII text, opens the file in text modeThis access type is optional:
"+"together withr,w, ora;r+orw+is read and write, whilea+is read and append
Return value
Result | Value |
|---|---|
Successful | The file handle |
Unsuccessful | An invalid file handle, which tests as False |
For use with
All C-SPY drivers.
Description
Opens a file for I/O operations. The default base directory of this macro is where the currently open project file (*.ewp) is located. The argument to __openFile can specify a location relative to this directory. In addition, you can use argument variables such as $PROJ_DIR$ and $TOOLKIT_DIR$ in the path argument.
Example
__varmyFileHandle; /* The macro variable to contain */ /* the file handle */myFileHandle= __openFile("$PROJ_DIR$\\Debug\\Exe\\test.tst", "r");if (myFileHandle) { /* successful opening */ }
See also
For information about argument variables, see the IDE Project Management and Building documentation.