Different usages of StrIndexWild
;------------------------------------------------------------------------------------------------------------------------------------------
; Divergencies between different strategies when using StrIndexWild and StrSubWild.
;------------------------------------------------------------------------------------------------------------------------------------------


#DefineSubRoutine udfStrSubWild (strString, strPattern, intStart)
Return StrSubWild (strString, strPattern, StrIndexWild (strString, strPattern, intStart))
; This UDS is only reliable for the first hit. Cannot be used in a loop. ???
#EndSubRoutine



strString = FileGet (IntControl (1004, 0, 0, 0, 0))
strPattern = "Str*ng"

intFoundA = 0
intWildPos = 0
While @TRUE
   strWild = udfStrSubWild (strString, strPattern, intWildPos)
   If strWild == "" Then Break
   intFoundA = intFoundA + 1
   Display (1, "A|Found=" : intFoundA : "|Pos=" : intWildPos, strWild)
   intWildPos = intWildPos + 1 + StrLen (strWild) ; Next starting position can only be guessed.
EndWhile


intFoundB1 = 0
intWildPos = 0
While @TRUE
   intWildPos = StrIndexWild (strString, strPattern, intWildPos)
   strWild = StrSubWild (strString, strPattern, intWildPos)
   If strWild == "" Then Break
   intFoundB1 = intFoundB1 + 1
   Display (1, "B1|Found=" : intFoundB1 : "|Pos=" : intWildPos, strWild)
   intWildPos = intWildPos + 1 + StrLen (strWild) ; Continue behind the last match result.
EndWhile


intFoundB2 = 0
intWildPos = 0
While @TRUE
   intWildPos = StrIndexWild (strString, strPattern, intWildPos)
   strWild = StrSubWild (strString, strPattern, intWildPos)
   If strWild == "" Then Break
   intFoundB2 = intFoundB2 + 1
   Display (1, "B2|Found=" : intFoundB2 : "|Pos=" : intWildPos, strWild)
   intWildPos = intWildPos + 1                    ; Continue behind the last match position.
EndWhile


Pause ("Search Result", "A=" : intFoundA : @LF : "B1=" : intFoundB1 : @LF : "B2=" : intFoundB2)

:CANCEL
Exit
;(c)Detlev Dalitz.20100209.
;------------------------------------------------------------------------------------------------------------------------------------------