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:44:45
 
 
To
12/01/2008 11:11:10
Mike Yearwood
Toronto, Ontario, Canada
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:
01281348
Views:
11
Thanks for the idea Mike!

>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
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform