578
Appendix A: System Routines — Files
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
FWrite
Declaration:
WORD
FWrite
(void *
buffer
, FSWORD
bytesToWrite
, FILES *
fsPtr
)
Category(ies):
Files
Description:
Write to a file returning FS_OK if successful. FS_ERROR if the file is not in
WRITE mode or FS_MEMORY if the system has run out of memory.
Inputs:
buffer
— Buffer to write to file.
bytesToWrite
— Number of bytes to write.
fsPtr
— Pointer to FILES structure previously opened with
FOpen
.
Outputs:
FS_OK — If successful.
FS_ERROR — File is not in write mode.
FS_MEMORY — Out of memory.
NOTE:
Any error will cause the file status to be set to FS_ERROR so that multiple
writes may be performed without checking the return status as long as an
FStatus
is done at the end to make sure all of the writes were successful.
Assumptions:
File is opened in WRITE mode.
Side Effects:
May cause heap compression.
Availability:
On AMS 2.00 and higher.
TI
-
89 / TI
-
92 Plus
Differences:
None
See Also:
None
Example:
FILE f1;
if (FS_OK == FOpen("APPDATA", &f1, FM_WRITE, "EXT" )) {
FWrite( "123456", 6, &f1 );
FWrite( "abc", 3, &f1 );
/* can check each FWrite or check FStatus when done with all writes */
if (FS_OK != FStatus( &f1 )) {
FClose( &f1 );
Disp("ERROR writing to file");
FDelete( "APPDATA" ); /* only have partial file */
return;
}
FClose( &f1 ); /* all writes were successful */
}