Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find position 1st occurrence of nonnumeric value in a st
Message
De
12/01/2008 11:11:10
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
11/01/2008 12:49:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01280661
Message ID:
01281342
Vues:
25
If you're concerned about performance yet want to keep the maintainability of a UDF, here's an option that I'm using regularly, when I don't habitually write the formula in the code.

I wrote an article for FoxPro Advisor where I took an expression and concatenated it into a SQL command. I stored the expression in a memo field in a format that supported parameters and named the formula (like a UDF) and managed to keep the speed almost as high as if the formula were hand-coded. I called the resulting formatted expression a snippet. It permits refinement of the formula in a single place just as does a UDF. It's also multi-developer friendly as the snippets are stored in a table.

http://my.advisor.com/doc/17440

You would instantiate the snippet factory object once at the beginning of the application.

This is how the snippet would be in the snippet table. I named it FirstNonNumericSnippet, but you can name it whatever makes it most understandable to you.

At(Left(Chrtran(<>, '0123456789', ''), 1), <>)

This is how you'd use it in an SQL command:

LOCAL m.loFirstNonNumericParameters
m.loFirstNonNumericParameters = ;
m.oSnippetFactory.GetParameterObject(;
"FirstNonNumericSnippet")
WITH m.loFirstNonNumericParameters
.SourceStringPlaceHolder = "yourfieldname"
ENDWITH

m.lcFirstNonNumericFormula = ;
m.oSnippetFactory.GetSnippet(;
m.loFirstNonNumericParameters)

TEXT TO lcSQL TEXTMERGE
select ;
<> ;
from sometable ;
into somecursor
ENDTEXT

&lcSQL.

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

Click here to load this message in the networking platform