Appendix A: System Routines — Files
567
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
FOpen
Declaration:
WORD
FOpen
(const char *
fileName
, FILES *
fsPtr
, WORD
mode
,
char *
typeName
)
Category(ies):
Files
Description:
Open a file for a specific mode.
Inputs:
fileName
— String pointer to name of file to open.
fsPtr
— Pointer to a structure of type FILES.
mode
— FM_READ
File must exist and can only be read.
FM_WRITE
Open file for writing and erase its contents.
Create file if it does not exist.
FM_APPEND
If file exists, open it for writing at the end of the
file. If it does not exist, then create it and open it
for writing.
typeName
— Must point to a string of, at most, four characters
that describes the file type (FS_ERROR is returned
if it does not). If there is an existing file with the
same name as
fileName
then the types must match.
Outputs:
FS_OK — The file was opened for the specified mode.
FS_ERROR — The file cannot be opened for the specified mode
(may be locked or is not a third-party data-type).
FS_BAD_NAME —
fileName
is invalid.
FS_MEMORY — Not enough memory.
The return value is also stored in
fsPtr
-> fileStatus.
The FILES pointer may then be used in subsequent file routines.
Assumptions:
Filenames are not tokenized variable names (as required by the symbol
table code) but rather a string of characters. They must not be reserved
names. If a filename does not have a folder name then it will be stored in
the current folder. Internally, FILEs are stored as third-party data-types
GEN_DATA_TAG). They will show up to the user in the VAR-LINK screen
as the type specified when the FILE was opened (up to four letters).
(continued)