ThisForm.nPosition = at("ErrorMessage", ThisForm.EdbText.Value) ThisForm.EdbText.SelStart = ThisForm.nPositionFor the second occurence, just add the third parameter to the at() function. If you are concerned about performance (because VFP will search from the beginning again), you might change to something like:
ThisForm.nPosition = at("ErrorMessage", substr(ThisForm.EdbText.Value),; ThisForm.nPosition)Where ThisForm.nPosition might either be the result of the previous search, or the position where the user left the cursor.
>m.lcString=This.parent.Beditbox1.Value && get error text > >WITH THISFORM > IF EMPTY(.pn_errorline) THEN > .pn_errorline = 1 && line no to start > .pn_errorline2 = 0 > ENDIF > > *--now go thru log and place pointer on error. > FOR lncnt= .pn_errorline TO ALINES(laArray,lcString) > m.lnerrNumber = VAL(ALLTRIM(Getword(ALLTRIM(SUBSTR(laArray[lncnt],AT(' ',laArray[lncnt])+1)),1))) && read each line > .pn_errorline2 = .pn_errorline2+LEN(laArray[lncnt]) > > IF m.lnerrNumber > 0 && we found an error > .pn_errorline = m.lncnt + 1 && this is where we start from next time > *--now place cursor > This.parent.Beditbox1.SetFocus > This.parent.Beditbox1.SelStart = .pn_errorline2 &&m.lncnt > This.parent.Beditbox1.SelLength = LEN(laArray[lncnt]) > m.lbfound = .T. > EXIT > ENDIF && IF m.lnerrNumber > ENDFOR > > IF EMPTY(lbfound) > MESSAGEBOX("Finished searching for ERROR(s)!",0+64,"Error Log") > .pn_errorline = 0 && ready to search again. > .pn_errorline2 = 0 > This.Caption = "\<Find error in log" > ENDIF >ENDWITH >