MPosToLc Function | |
Return the line and column position of a character in a formatted string.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION MPosToLc(
cText,
nWidth,
nPos,
nTabSize,
lWrap
) AS ARRAY CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public static Array MPosToLc(
Usual cText = default,
Usual nWidth = default,
Usual nPos = default,
Usual nTabSize = default,
Usual lWrap = default
)
Request Example
View SourceParameters
- cText (Optional)
- Type: Usual
A string. - nWidth (Optional)
- Type: Usual
The length of each line after cText is formatted.
- nPos (Optional)
- Type: Usual
The byte position within the formatted text, counting from 1. - 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:
Array
An array containing the line and column numbers for the character at the specified position.
Remarks
MPosToLC() identifies the formatted line and column that correspond to a particular character position within cText. Note that the line number returned is 1-relative, and the column number is 0-relative.
This is compatible with MemoEdit(). nPos is 1-relative, which is compatible with At(), RAt(), and other string functions.
MPosToLC() is used with MLCToPos() to create search routines or other text processing for MemoEdit().
Examples
This example determines the line and column corresponding to the tenth character of the text string shown, assuming a formatting width of five columns.
A formatting width of five would cause each of the first 3 words to be placed on a line by itself.
The tenth character of the text is the "s" in "side."
The word "side" would be at the leftmost column of the third line of the formatted text, so the return value is {3, 0}:
1cText := "Note the side on which the bread" + "is buttered."
2aLC := MPosToLC(cText, 5, 10)
See Also