>Unfortunately, as I just found, type doesn't return correct results, if UDF is used, e.g.
>type("trimzero('00034')") returns U, while vartype(trimzero('00034')) returns C (trimzero is custom function, which removes leading 0s).
I have seen this problem a few years ago in FoxPro. As to the reasons, I came to the following conclusion:
For a built-in function, VFP (or FoxPro) knows the expected return type. The type can be determined without actually evaluating the function.
For a UDF, there is currently no way to tell VFP that your UDF normally returns such-and-such a type. There is no way for VFP to tell you the type of the expression without actually calling the function. This may have undesirable side-effects: your UDF might do almost anything, or produce an error.
For these reasons, although it is unpleasant not to be able to easily get the type of your expression with type(), I find VFP's behavior perfectly logical.
Regards,
Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)