# ReadLine

int ReadLine (int fileHandle, char lineBuffer[], int maximum#Bytes);

## Purpose

Reads bytes from a file until it encounters a linefeed (LF) and places up to maximum#Bytes bytes, excluding the LF, into a buffer. If the number of bytes read exceeds a specified maximum, ReadLine discards the excess bytes so that the buffer does not overflow.

| Note ReadLine adds an ASCII NUL byte at the end of the bytes read.

## Parameters

Input
Name | Type | Description
fileHandle | integer | Specifies the file from which the line is to be read. Call OpenFile to obtain fileHandle. Open the file in ASCII mode so that ReadLine treats a carriage return/linefeed (CR/LF) combination as an LF. If fileHandle is zero, ReadLine reads the line from the Standard I/O window.
maximum#Bytes | integer | Maximum number of bytes, excluding the ASCII NUL, to read into the line. Once ReadLine reaches the maximum, it discards bytes until it reads an LF. If you enter –1 into this control, then no maximum will be applied.
| Note This value must be at least one less than the number of bytes in the buffer variable.
Output
Name | Type | Description
lineBuffer | string | Specifies the variable where the line is to be stored. This variable must be large enough to contain maximum#Bytes bytes plus an ASCII NUL.

## Return Value

Name | Type | Description
n | integer | Number of bytes ReadLine reads from the file, including discarded bytes, but excluding LF. Hence, the return value exceeds maximum#Bytes if bytes are discarded. If ReadLine reads no bytes because it has already reached the end of the file, it returns –2. If an I/O error occurs, possibly because of a bad file handle, ReadLine returns –1. You can use GetFmtIOError to get more information about the type of error that occurred. A value of 0 indicates that ReadLine read an empty line.