Topic Path: Symbol Reference > Functions > ReadLnFromStream Function
ContentsIndexHome
PreviousUpNext
ReadLnFromStream Function

Reads a line of text from a stream.

File
function ReadLnFromStream(
    AStream: TIdStream; 
    AMaxLineLength: Integer = -1; 
    AExceptionIfEOF: Boolean = FALSE
): string;
Parameters 
Description 
AStream 
Stream used to read a line of text.
 
AMaxLineLength 
Maximum number of characters allowed in the line read from the stream. Default value is -1.
 
AExceptionIfEOF 
Indicates if an exception is raised when the end of the stream is encountered. Default value is FALSE. 

string - Line of text read from the stream, or an empty string when no data is available.

ReadLnFromStream is a String function used to read a line of text from the stream specified in AStream. ReadLnFromStream raises an EAssertionFailed exception if the stream instance in AStream has not been assigned (or contains a Nil value). 

AMaxLineLength indicates the maximum number of characters allowed in the line read from the stream. The default value is -1 and indicates that up to MaxInt chatacters are allowed in the return value for the function. 

AExceptionIfEOF indicates if an EIdEndOfStream exception should be raised when an unexpected end of stream occurs during a read operation on the stream. The default value is False. 

The return value for the function contains any text read using the specified arguments, or an empty string ('') when no data is available or an unexpected end of stream occurs for the stream instance. The line of text is considered to be complete the end of the stream is reached, when the maximum number of characters is exceeded, or when an end-of-line character sequence is found. An end-of-line character sequence includes any of the following values: 

 

CR 
LF 
CRLF 

 

ReadLnFromStream allocates a 2048 byte buffer (2k) used to when reading values from the stream instance in AStream. When reading values for the line of text, ReadLnFromStream fills the internal buffer when required using the ReadTIdBytesFromStream procedure. ReadLnFromStream calls the BytesToString routine to convert the array of bytes to the string data type used in the return value. 

Use one of the following common stream routines to read or write the associated ordinal data type using a stream instance: 

 

Exceptions 
Description 
EAssertionFailed 
Raised when the stram instance for the read operation is unassigned (contains the value Nil).
 
Raised when an unexpected end of stream condition occurs and the AExceptionIfEOF argument contains True. 
Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.