| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Scans a formatted character string or memo field for text lines.
HB_ReadLine( <cText> , ;
[<cDelim>|<aDelim>], ;
<nLineLen> , ;
[<nTabWidth>] , ;
<lWrap> , ;
[<nStartOffset>] , ;
@<lFound> , ;
@<lEOF> , ;
@<nEndOffSet> , ;
@<nEndOfLine> ) --> NIL
The return value is always NIL.
HB_ReadLine() is a fast text scanning function used to extract single text lines from a formatted text string that may include Tab characters (Chr(9)), Soft carriage returns (Chr(141)) or Hard carriage returns (Chr(13)). Text is usually scanned for single lines within a DO WHILE loop until <lEOF> is .T. (true).
| See also: | FLineCount(), HB_FReadLine(), MemoEdit(), MemoLine(), MemoRead(), MemoWrit(), MLCount(), MLPos() |
| Category: | Character functions , Memo functions , xHarbour extensions |
| Source: | rtl\txtline.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example demonstrates how an entire text file can be transferred
// line by line into an array.
PROCEDURE Main
LOCAL cText := MemoRead( "HB_ReadLine.prg" )
LOCAL nLineLen := 60
LOCAL lWrap := .T.
LOCAL nEndOfLine := 0
LOCAL nStartOffset := 1
LOCAL nEndOffSet := 0
LOCAL lFound := .F.
LOCAL lEof := .F.
LOCAL aLines := {}
LOCAL cLine
CLS
DO WHILE .NOT. lEof
HB_ReadLine( cText , ;
NIL , ;
nLineLen , ;
NIL , ;
lWrap , ;
nStartOffset, ;
@lFound , ;
@lEof , ;
@nEndOffset , ;
@nEndOfLine )
cLine := SubStr( cText, nStartOffset, nEndOffset-nStartOffset+1 )
IF cLine == ""
cLine := " " // empty line for AChoice()
ENDIF
AAdd( aLines, cLine )
nStartOffSet := nEndOfLine
ENDDO
AChoice( ,,,, aLines )
RETURN
http://www.xHarbour.com