Opened 4 years ago

Closed 2 years ago

#3633 closed Bug (Fixed)

_GUICtrlRichEdit_FindText does not flag failure to find CR

Reported by: davidjudysmith@… Owned by: Jpm
Milestone: Component: Standard UDFs
Version: Severity: None
Keywords: Rich Edit, FindText, Carriage return Cc:


There seems to be a problem with _GUICtrlRichEdit_FindText, or at least a problem with its documentation.

The attached script FindTextTest.au3 illustrates the problem. The script creates a Rich Edit control and fills it with three lines, one of which is blank; each line is followed by a CR. The For loop sets the character position, initially at the beginning of the text, then searches for the next CR character. Results of these searches are reported in a MsgBox when the loop completes.

According to the documentation, _GUICtrlRichEdit_FindText should return "the inter-character position before start of matching text if found, else -1." But my test program never gets a -1 from that function, even when it is obviously searching beyond the end of the text.

The third pass through the For loop correctly returns the position of the last CR. The fourth pass should return a -1 status or a code in @error, because there are no more CR characters, but it does not. In the last two passes, the FindText function returns a value that is one less than the starting position, apparently because the starting position is beyond the end of the text, but that behavior is not documented. (Note that GotoCharPos does not fail.) The error only comes from GetTextInRange, because End<Start.

I suggest one or more of the following:

  • Return a failure from GotoCharPos if the position is beyond the end of the text;
  • Correctly handle searches for CR characters, which seem to be different from printable characters;
  • Provide a different way to search for CR characters (actual end of a line/paragraph, not just end of displayed line);
  • Document that FindText returns the position of the end of the text, if it is started beyond that point, or generate an error in that case.

Note also that _GUICtrlRichEdit_GetTextLength returns a number that's larger (25 vs 22) than the actual number of characters. That makes it useless for a comparison with character positions.

Attachments (1)

FindTextTest.au3 (1.6 KB) - added by davidjudysmith@… 4 years ago.
Test script, showing that _FindText doesn't report failure

Download all attachments as: .zip

Change History (3)

Changed 4 years ago by davidjudysmith@…

Test script, showing that _FindText doesn't report failure

comment:1 Changed 2 years ago by Jon

  • Component changed from AutoIt to Standard UDFs

comment:2 Changed 2 years ago by Jpm

  • Milestone set to
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [12330] in version:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Jpm.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.