>I understand that it not fires with the wait waindow and it is o.k.
>
>But, what I don't understand it's WHY it is execute in the SELECT ?
>
>It's not supposed to be execute !
It must have something to do with the order of execution, and Fox is calling the test() function to get the expression ready in case it is needed -- probably once when it first parses the SELECT statement, and once when it executes it for your 1 record.
A better approach would probably be to call a function with the cValue as a parameter, and let the function handle the logic and return whatever is needed:
SELECT myfunc(cValue) AS textvalue...
Just be sure to pad the result to the desired length before returning the value.