Click or drag to resize

MLcToPos Function

X#
Return the position of a character in a formatted string.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION MLcToPos(
	cText,
	nWidth,
	nLine,
	nCol,
	nTabSize,
	lWrap
) AS DWORD CLIPPER
Request Example View Source

Parameters

cText (Optional)
Type: Usual
A string.
nWidth (Optional)
Type: Usual
The length of each line after cText is formatted.
nLine (Optional)
Type: Usual
The line number in the formatted text, starting from the top at 1.
nCol (Optional)
Type: Usual
The column number in the formatted text, starting from the left at 0.
nTabSize (Optional)
Type: Usual
The number of characters to insert when the user presses Tab.
If nTabSize is not specified, 4 spaces are inserted.
lWrap (Optional)
Type: Usual
The word-wrap flag.
The default is TRUE.

Return Value

Type: DWord
The byte position of the character within cText, counting from 1.
Remarks
MLCToPos() determines the character position that corresponds to a particular line and column within formatted text. Note that the line number is 1-relative, and the column number is 0-relative.
This is compatible with MemoEdit().
The return value is 1-relative, making it suitable for use in Substr() or other string functions. MLCToPos() is used with MPosToLC() to create search routines or other text processing for MemoEdit().
Examples
This example gives the current position of the character that will appear in line 3, column 0 when cText is formatted with a line length of 5 characters:
X#
1cText := "Note the side on which the bread" + "is buttered."
2? MLCToPos(cText, 5, 3, 0)        // Result: 10
See Also