SelStart - DFBaseTextEdit
Returns beginning position of selection
Type: Function
Return Data Type: integer
Syntax
Function SelStart Returns integer
Call Example
Get SelStart to integerVariable
Description
Returns beginning position of selection.
Returns the first character position inside the selection. If no text is selected, returns the current position of the caret.
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. So, if the first line in the control contains 20 characters, and the selected text is characters 5 through 10 of the second line, the return value of SelStart will be 25.
Sample
This sample gets the beginning and ending position of the selected text of control oTextEdit1 and then displays the selection range (or length) to the user in a message box.
Procedure ShowSelectionRange
Integer iSelStart iSelEnd
Get SelStart of oTextEdit1 to iSelStart
Get SelEnd of oTextEdit1 to iSelEnd
Send Info_Box (string(iSelStart) + " to " + string(iSelEnd)) "Range of selected text"
End_Procedure
This class does not have an insert (bold) function, but we can easily add one:
Procedure Insert String sInsertText
Integer iPos
String sText
Get SelStart to iPos
Send SetSel iPos -1
Get SelText to sText
Move (sInsertText + sText) to sText
Send ReplaceSel sText
End_Procedure
It can be called like this:
Procedure OnClick
String sText
Get Value of oInsertTextForm to sText
Send Insert of oTextEditor sText
End_Procedure
Return Value
Beginning position of selection.