Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Placing cursor in editboxes
Message
From
29/08/2005 23:21:10
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
29/08/2005 23:00:59
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01044974
Message ID:
01045015
Views:
36
This message has been marked as a message which has helped to the initial question of the thread.
>I tried this Hilmar.it is highlighting first error correctly but not the next ones.
>as you'll see am storing len of chars in form level property as parsing thru text.
>
>can you tell where my logic going wrong?? Thanks

Much too complicated, I think. You don't need to use alines(); just search for the first occurence by searching in the entire text.
ThisForm.nPosition = at("ErrorMessage", ThisForm.EdbText.Value)
ThisForm.EdbText.SelStart = ThisForm.nPosition
For 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.

Of course, to this very basic code, a few things might be added; especiall a check for "not found".





>
>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
>
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform