Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Special Filter
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
01090451
Message ID:
01090726
Vues:
7
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform