Will try to OPEN the given file using the next free number and the desired mode. On success it will also properly lock the file according to the mode. The opening is safe in that way, as it traps any errors and so avoids the abortion of the running program. In case of an error, the function does return a zero result, while the error code is saved into the globally SHARED variable appLastErr% for later reference.
SYNTAX:
fid% = SafeOpenFile% (mode$, file$)
INPUTS:
mode$ (STRING)
- The desired file mode (INPUT, OUTPUT etc.), may be a shortcut, only the first char is mandatory. You may use upper, lower or mixed case chars.
file$ (STRING)
- The name of the file to open. May have a full or relative path, if required.
RESULT:
fid% (INTEGER)
- The number of the opened file on success or zero on failure.
- On failure you may check the error code in the appLastErr% variable and use it to control the further program flow.
- If required, you may also forward the error to the global user error handler using the statement ERROR appLastErr%.