Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find position 1st occurrence of nonnumeric value in a st
Message
From
12/01/2008 11:11:10
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
11/01/2008 12:49:20
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01280661
Message ID:
01281342
Views:
11
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform