Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Searching for a substring in a field - fastest way
Message
De
10/03/2017 12:46:41
 
 
À
09/03/2017 14:30:30
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01648880
Message ID:
01648908
Vues:
47
>What is the fastest way to search through a file to find a substring within a field? I know you can
>
>set filter to 'xyz" $ yourfield
>go top
>
>or an SQL Select equivalent, but in a file where there are thousands of records, it takes a long time, specially on a network...
>
>Is there a quicker way?
>
>Many thanks!
John,
you could try to make use of following procedure:

parameter tcFldContent = value to be searched for
parameter tcDataType = type of data of field you are searching
parameter tcFldName = name of field your are investigating
Parameter tcFldContent, tcDataType, tcFldName

If  Vartype(tcFldContent) <> 'C'
	Return
Else
	lcFieldValue = tcFldContent
Endif
If Vartype(tcDataType) <> 'C'
	lcDateType = tcDataTyepe
	Return
Else
	lcDataExpression = tcDataExpression
Endif

If Vartype(tcFldName) <> 'C'
	Return
Else
	lcFlieldName = tcFldName
Endif

Do Case
	Case m.lcDateType = "T"
		Return "AT("+m.lcFieldValue +",TTOC("+m.lcFlieldName +"))>0"
	Case m.lcDataType = "D"
		Return "AT("+m.lcFieldValue +",DTOC("+m.lcFlieldName +"))>0"
	Case Inlist(m.lcDataType,"N","F","I","Y","B")
		Return "AT("+m.lcFieldValue +",ALLTRIM(STR("+m.lcFlieldName +")))>0"
	Case m.lcDataType = "M"
		Return "ATC("+m.lcFieldValue +","+m.lcFlieldName +")>0"
	Otherwise
		Return "AT("+m.lcFieldValue +","+m.lcFieldName +")>0"
Endcase
Regards,

Koen
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform