National Instruments 320682C Musical Toy Instrument User Manual


 
Formatting and I/O Library Chapter 2
LabWindows/CVI Standard Libraries 2-22 © National Instruments Corporation
fileType specifies whether to treat file as ASCII or binary. When performing I/O on a file in
binary mode, no special treatment is given to carriage returns (CR) and line feeds (LF). When
you open the file in ASCII mode, CR LF combination translates to LF when reading, and LF
translates to CR LF when writing. fileType values are as follows:
VAL_BINARY = binary
VAL_ASCII = ASCII
ReadFile
int n = ReadFile (int fileHandle, char buffer[], int count);
Purpose
Reads up to count bytes of data from a file or STDIN into buffer. Reading starts at the current
position of the file pointer. When the function completes, the file pointer points to the next
unread character in the file.
Parameters
Input
fileHandle
integer File handle.
count
integer Number of bytes to read.
Output
buffer
string Input buffer.
Return Value
n
integer Number of bytes read.
Return Codes
-1
Error, possibly bad handle.
0
Tried to read past end-of-file.
Parameter Discussion
fileHandle is the file handle returned by the OpenFile function. fileHandle points to the file
from which you want to read. If fileHandle =0, input is read from STDIN, and no prior
OpenFile call is needed. buffer is the buffer into which you read data. You must allocate
space for this buffer before you call this function. count specifies the number of bytes to read.
count must not be greater than buffer size.