National Instruments 320682C Musical Toy Instrument User Manual


 
Chapter 2 Formatting and I/O Library
© National Instruments Corporation 2-23 LabWindows/CVI Standard Libraries
Using This Function
The return value can be less than number of bytes requested if end of file was reached before
byte count was satisfied. Notice that if you open the file in ASCII mode, each CR LF
combination read is counted as 1 character, because the pair is translated into LF when stored in
the buffer.
Note: This function does not terminate the buffer with an ASCII NUL.
ReadLine
int n = ReadLine (int fileHandle, char lineBuffer[], int maximum#Bytes);
Purpose
Reads bytes from a file until a linefeed is encountered.
Parameters
Input
fileHandle
integer File handle.
maximum#Bytes
integer Maximum number of bytes to
read into line, excluding the
ASCII NUL.
Output
lineBuffer
string Input buffer.
Return Value
n
integer Number of bytes read,
excluding linefeed.
Return Codes
-2
End of file.
-1
I/O error.
Parameter Discussion
This function places up to maximum#Bytes bytes, excluding the linefeed, into lineBuffer.
Appends an ASCII NUL to lineBuffer. If there are more than maximum#Bytes bytes before the
linefeed, the extra bytes are discarded.
fileHandle is the file handle that was returned from the OpenFile function and specifies the
file from which to read the line. The file should be opened in ASCII mode so that a