Function MlPos() Foundation
Determines starting position of the specified line in a formatted character string.
MlPos( <cString> , ;
<nLineLen> , ;
<nRow> , ;
[<nTabSize>], ;
[<lWrap>] ) --> nPosition
MlPos() returns the position of the first character in the row <nRow> within <cString> as an integer numeric value. When <nRow> is greater than the entire number of rows in <cString>, Len(<cString>) is returned.
The memo function MlPos() is similar to the function MlCtoPos() and returns an exact position within a character string which may contain formatting characters. MlPos() differs from MlCtoPos() in that it uses only row position and returns the start position of the indicated row.
// In this example, MlPos() is used to send the contents of a file
// page by page to the printer along with page headers which
// include the page numbers as well as the date and time.
PROCEDURE Main
LOCAL nLineLen := 55
LOCAL nPageLen := 50
LOCAL nPageNum := 1
LOCAL nPos
cString = MemoRead("TEXTFILE.TXT")
SET MARGIN TO 8
DO WHILE Len( cString ) > 0
SET PRINTER OFF
SET CONSOLE ON
DO WHILE .NOT. IsPrinter()
@ 0,0 SAY "Printer not ready"
Inkey(1)
IF LastKey()==K_ESC
@ 0,0 SAY "Printing was aborted"
cString := ""
EXIT
ENDIF
ENDDO
@ 0,0 SAY "Printing page No:"
?? nPageNum
SET PRINTER ON
SET CONSOLE OFF
? PadL( "Page: "+Str(nPageNum,8), nLineLen )
? PadL( "Date: "+DtoC(Date()) , nLineLen )
? PadL( "Time: "+Time() , nLineLen )
nPos := MlPos( cString, nLineLen, nPageLen )
? SubStr( cString, 1, nPos - 1 )
cString := SubStr( cString, nPos )
nPageNum ++
EJECT
ENDDO
SET MARGIN TO
SET PRINTER OFF
SET CONSOLE ON
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.