Was in "don't think, do" mental state. In that case
>>BTW
>>
return eval (
iif (SEEK( tcValue, tcAlias, tcTag ) ;
, tcReturnField;
, "CAST(' ' as " + type(tcReturnField) +")" ;
)
is much shorter and as a one-liner most of the time creates faster running p-code.
The else-branch is now also evaluated, but base expression does not need the icase checking branches depending on parameter type.
As this is now a one-liner, a program could be written to expand the previous udf call in all source files.
@Mike: guessing at the wrapper call frequency and possible optimizations: if your main trouble lies in SQL calling the UDF millions of times, how about thinking to create a &Makroexpression? During loop execution they are a big no-no, but if used in SQL they are Makro-executed only once and the generated source expression is used without penalty for all records, eliminating the wrpper udf call.