2.16 :findtext()

The :findtext() method searches for a given string in the text (.content) of an edittext.

Definition

integer :findtext
(
      string  Text  input
  { , integer Start := 1  input,
      integer End   := -1 input }
  { , boolean CaseSensitive := true input }
)

Parameters

string Text input

This parameter passes the string to be searched for in the content of the edittext.

An empty text is found immediately. The return value of :findtext() will then be Start if a range was specified and the cursor position or the end position of the selection if no range was specified.

For the RTF edittext (.options[opt_rtf] = true), the text to be searched for has to be passed as plain text without formatting instructions.

integer Start := 1 input
integer End := 1 input

These optional parameters define the range in which to search for the specified string. If no range is given, the search starts at the cursor position or after the selection and continues until the end of the text.

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 break characters therefore count as well.

-1 can be specified for End to search the contents of the edit text to its end.

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.

boolean CaseSensitive := true input

This optional parameter determines whether the search will be case-sensitive.

true
Upper and lower case of the found texts must match the specified string.
false
Upper and lower case of the found texts may differ from the specified string.

Return value

-1
The specified string was not found.
>= 0
Starting position for the first occurrence of the specified string in the text.

Objects with this method

edittext