xHarbour Reference Documentation > Function Reference |
Extracts the next line from a text file.
HB_FReadLine( <nFileHandle> , ; @<cLine> , ; [<caEndOfLine>], ; [<nLineLength>] ) --> nReturn
The function returns 0 when the next text line is read from the file. A value not equal zero is returned when no more lines are available to read.
HB_FReadLine() is an efficient extraction routine for getting the next available line from an ASCII text file. It differs from FReadStr() in allowing a programmer to define the end-of-line character(s) HB_FReadLine() should recognize. Also, the maximum length of a line to search for the next end-of-line character(s) can be specified. The default value of 4096 is sufficient for most common text files.
See also: | FOpen(), FClose(), FCreate(), FReadStr(), MemoLine(), MemoRead() |
Category: | Low level file functions , xHarbour extensions |
Source: | rtl\fnsplit.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates an efficient way of loading single lines // from an ASCII file into an array. PROCEDURE Main LOCAL cFileName := "HB_FReadLine.prg" LOCAL aLines := {} LOCAL nFileHandle := FOpen( cFileName ) LOCAL cLine DO WHILE HB_FReadLine( nFileHandle, @cLine ) == 0 AAdd( aLines, cLine ) ENDDO // Add the last line AAdd( aLines, cLine ) FClose( nFileHandle ) ? Len( aLines ) AEval( aLines, {|c| QOut( c ) } ) RETURN
http://www.xHarbour.com