2.34 :replacetext()
The :replacetext() method substitutes text in an edittext with another text.
Definition
boolean :replacetext ( { integer Start := 1 input, integer End := -1 input, } { enum Type := content_plain input, } string Text input )
Parameters
- integer Start := 1 input
integer End := -1 input -
These optional parameters define the range to be replaced by the specified string. If no range is specified, the selection, that is, the range from .startsel to .endsel, is replaced by the specified string. .startsel and .endsel are placed at the end of this text, i.e. after the replacement, the cursor is positioned behind the inserted text. If a range is specified, .startsel and .endsel retain their values, unless the replacement makes this impossible.
The value range of Start and End goes from 0 to the number of characters in the displayed text, with every character that can be included in a selection counting. Line and paragraph breaks therefore also count as characters.
-1 can be specified for End to replace the remaining text from the start position.
With the RTF edittext (.options[opt_rtf] = true), Start and End – similar to .startsel and .endsel – refer to positions in the formatted text. They cannot be used to infer positions in the content string of the RTF edittext, since this also contains formatting instructions. If the Start or End parameters are greater than the text length, then the text length is used for the RTF edittext.
- enum Type := content_plain input
-
For the RTF edittext, this optional parameter specifies whether the string to be inserted contains plain, unformatted text or RTF text.
Value range
- string Text input
-
This parameter passes the string that will replace text in the RTF edittext.
Return value
- true
- Text range in the edittext has been replaced by the specified string.
- false
- Error: There was no substitution.
Objects with this method