Chapter 13: Memory Management
133
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
There is no separate mode to open a file for both reading and writing. However, if
a file is opened in FM_APPEND mode the contents of the file are not erased. All
locations in the file can either be read from or written to (random access).
The file routines are:
FClose
— Close a file, this is required for files opened in write
mode.
FCreate
— Create an empty file.
FDelete
— Delete a file.
FEof
— Return TRUE if a file is at the End of File mark.
FFindFirst, FFindNext
— Used to search all files for a specific file type.
FGetC
— Return a byte from an open file.
FGetPos
— Return the current file position.
FGetSize
— Return the number of bytes stored in an opened file.
FOpen
— Open a file for reading, writing or both.
FPutC
— Write a byte to a file opened in write mode.
FRead
— Read multiple bytes from a file.
FSetBufSize
— Set the size of the write buffer for an opened file.
FSetPos
— Set the position of the next read or write for an opened
file.
FSetSize
— Truncate the size of a file opened in write mode.
FSetVer
— Change the version number of an opened file.
FStatus
— Return the status of an opened file.
FType
— Return the file type (description field) of a file.
FWrite
— Write multiple bytes to an opened file.
13.2.1. Opening Multiple Files for WRITE Mode
This section is only relevant if you plan on opening multiple files simultaneously
in write mode. It requires some understanding of variables, specifically HSYMs
which are explained in the next section. The FILES structure contains an HSYM
of the opened file. HSYMs can become invalid whenever a new symbol table
entry is added or a previous one is removed. In the FILE system the problem of
HSYMs becoming invalid is only a problem if multiple files must be opened at the
same time in WRITE or APPEND mode. Since the file system stores the HSYM
of all opened variables in the FILES structure (this is needed for when the file is
closed), creating a new file (which is just a symbol) with an existing file opened in
WRITE mode may invalidate the previous file’s HSYM. To get around this
problem in the file system just use
FCreate
to create multiple files that must be
opened simultaneously in WRITE mode before they are opened. This will insure