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/17440You 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