Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Special Filter
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01090451
Message ID:
01090726
Views:
8
>I need to filter in a list of products those contaning all words I type. Example:
>
>If I type "red pencils" and my list is:
>
>1-This are red pencils
>2-Somes pencils are red
>3- I need a pencil
>
>Only 1 and 2 satisfy the filter. Any easy way to do this with SET FILTER TO?

this can support 23 words,of course, speed can become a problem :
CREATE CURSOR mylist (text M)
INSERT INTO mylist VALUES ("This are red pencils")
INSERT INTO mylist VALUES ("Somes pencils are red")
INSERT INTO mylist VALUES ("I need a pencil red for you")


filterWords("text","red pencils")
BROWSE
filterWords("text","red pencils are")
BROWSE
filterWords("text","red pencils are This")
BROWSE

PROCEDURE filterWords(eText,cWords)
	PRIVATE aWords,cFilter
	IF BETWEEN(ALINES(aWords,m.cWords," "),1,23)
		cFilter=[ALINES(adummy,]+m.eText+[,2,"]+aWords[1]+["]
		FOR w=2 TO ALEN(aWords)
			cFilter=m.cFilter+[,"]+aWords[m.w]+["]
		NEXT
		cFilter=m.cFilter+[)>]+LTRIM(STR(ALEN(aWords)))
		SET FILTER TO &cFilter
	ELSE
		SET FILTER TO
	ENDIF
Previous
Reply
Map
View

Click here to load this message in the networking platform