LineFromChar - DfBaseRichEdit
Returns number of line that contains specified character position or current line
Type: Function
Return Data Type: integer
Parameters
| Parameter | Type | Description |
|---|---|---|
| iCharPos | integer | Position of character |
Syntax
Function LineFromChar integer iCharPos Returns integer
Call Example
Get LineFromChar iCharPos to integerVariable
Description
Returns zero-based number of the line that contains specified character position (iCharPos) or current line.
If iCharPos is -1, returns the line number of the current line. If text is selected, returns the line number of the beginning of the selected text.
If iCharPos is greater than total number of lines in control, function returns -1.
The character position is the zero-based absolute position of the character in the control. The first position in the first line is always 0. If the first line in the control contains 20 characters, the first position in the second line will be 20.
This method has no effect if control is not paged.
Sample
This sample gets the text of the current line in control oRichEdit1 and displays it to the user in a message box. The current line text is retrieved by calling function Line with the current line number.
Procedure DisplayCurrentLine
integer iFirstCharPos iLineNum iCurrentLineNum
string sLine
// indicates that we want the current line
move -1 to iLineNum
// get the line number of the current line
get LineFromChar of oRichEdit1 iLineNum to iCurrentLineNum
// get the text of the current line
get Line of oRichEdit1 iCurrentLineNum to sLine
send Info_Box sLine ("Line number " + string(iCurrentLineNum))
End_Procedure // DisplayCurrentLine
Return Value
Zero-based number of the line that contains specified character position (iCharPos) or current line.