| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Determines the starting position of a line in a formatted character string or memo field.
MlPos( <cString> , ;
[<nLineLen> , ;
[<nLineNum>] , ;
[<nTabSize>] , ;
[<lWrap>] , ;
[<lLongLines>] ) --> nPosition
The function returns the starting position of the text line having number <nLineNum> in <cString>. Position counting starts with 1.
MLPos() is used similar to MLCToPos() for finding an exact byte position in a formatted text string. MlPos() ingnores column positions within a text line and searches only for the beginning of a line of text.
| See also: | MemoLine(), MemoTran(), MLCount(), MLCToPos(), MPosToLC() |
| Category: | Character functions , Memo functions |
| Source: | rtl\mlpos.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// This example determines the starting position of the 4th line
// when the text string is formatted with 10 characters per line:
PROCEDURE Main
LOCAL cString := "The quick brown fox jumps over the lazy dog"
LOCAL cLine := ""
LOCAL nLineLen := 10
LOCAL i, imax := MLCount( cString, nLineLen )
? '"' + cString + '"'
?
FOR i:=1 TO imax
cLine := MemoLine( cString, nLineLen, i )
? '"' + cLine + '"'
NEXT
// Output so far:
// "The quick brown fox jumps over the lazy dog"
//
// "The quick "
// "brown fox "
// "jumps over"
// "the lazy "
// "dog "
?
? i := MLPos( cString, nLineLen, 4 ) // result: 32
? SubStr( cString, i, nLineLen ) // result: the lazy d
RETURN
http://www.xHarbour.com