FutureBasic Logo

<<    Index    >> FutureBasic

write file   function / statement



Syntax 1
[ result =] write file fileID , cfString [ , @err ]

Syntax 2
write file [ # ] deviceID, address, numberBytes

Description

Syntax 1:
This function writes a CFString to the open file and optionally returns a boolean to indicate success or failure.

Important note: write file's syntax 1 must be matched with the correct open method for use with CFStrings. See syntax 1 for open.

Example

CFStringRef string = @"Hello, World!"
ErrorRef err = NULL
BOOL result = write file 1, string, @err
if ( !result )
print err
end if

Syntax 2:

This statement writes numberBytes of data to the open file or serial port specified by deviceID, starting at the current "file mark" position. The data is copied from the memory which starts at address. This is generally the fastest way to write a large amount of data to a file.

Important note: write file's syntax 2 must be matched with the correct open method for use with a pointer to a buffer. See syntax 2 for open.

Example

This program fragment saves the binary image of an array into an open file. You can later use the read file statement to load the array using the data in the file (see the example accompanying the read file statement).

_maxSubscript = 200
SInt16 myArray(_maxSubscript)
UInt32 arrayBytes

arrayBytes = (_maxSubscript + 1) * sizeof(SInt16)
write file #1, @myArray(0), arrayBytes
See also
open; write; read file