Ticket #3633: FindTextTest.au3

File FindTextTest.au3, 1.6 KB (added by davidjudysmith@…, 7 years ago)

Test script, showing that _FindText doesn't report failure

Line 
1
2#include <GuiRichEdit.au3>
3
4Local $Text = "First line" & @CR & @CR & "Last line" & @CR
5Local $iStart, $iEnd, $Line, $i
6Local $TextLen
7Local $FindTextError, $GetTextError
8Local $MsgBuff = ""
9
10Local $hGUI = GUICreate ("Find Text Test", 300, 300)
11Local $hRichEdit = _GUICtrlRichEdit_Create ($hGUI, "", 10, 10, 280, 280)
12GUISetState(@SW_SHOW, $hGUI)
13
14_GUICtrlRichEdit_SetText ($hRichEdit, $Text)
15$iStart = 0
16$TextLen = _GUICtrlRichEdit_GetTextLength ($hRichEdit, True, True)
17$MsgBuff = $TextLen & " characters in Rich Edit box"
18For $i = 1 to 6
19   If Not _GUICtrlRichEdit_GotoCharPos ($hRichEdit, $iStart) Then       ; Does GotoCharPos complain about going beyond the end?
20          MsgBox (0, "", "False from GotoCharPos")      ; This never happens
21          ExitLoop
22   EndIf
23   $iEnd = _GUICtrlRichEdit_FindText ($hRichEdit, @CR)  ; Find the next CR
24   If $iEnd = -1 Then ExitLoop          ; FindText should return -1 if not found, but it doesn't
25   $FindTextError = @error
26   If $iEnd = $iStart Then
27          $Line = ""    ; end = start just means a blank line
28          $GetTextError = 0
29   Else
30          $Line = _GUICtrlRichEdit_GetTextInRange ($hRichEdit, $iStart, $iEnd)  ; the line is all characters between start and end
31          $GetTextError = @error
32   EndIf
33   $MsgBuff &= @CRLF & $i & ": Start = " & $iStart & ", End = " & $iEnd & ": <" & $Line & ">  (@errors = " & $FindTextError & ", " & $GetTextError & ")"        ; accumulate results
34   $iStart = $iEnd + 1  ; Next search starts one character after the last found CR
35Next
36MsgBox (0, "Test results", $MsgBuff)
37_GUICtrlRichEdit_Destroy($hRichEdit)
38GUIDelete($hGUI)
39Exit