Thomas is already giving you plenty of food for thought. I'll just add a small remark around this,
hoping it will help to clarify how TYPE() works in VFP.However a function such as Type or Eval could also receive a string in the form of:
which is an assignment. It should still return "N" because the value in MyLocal is numeric after the assignment.Code: Select all
Type ("MyLocal = 10")
The argument of TYPE() is a string representing an expression that can be highly complex, just like in EVALUATE(). The difference between the two is that TYPE() returns the type of the evaluated expression, while EVALUATE() returns the result of the evaluated expression.
In both cases, the full-blown VFP evaluator parses and calculates the expression. The scope for the expression is the scope of the caller.
"MyLocal = 10" is not, in any case, an assignment: it's a logical expression, with two operands (MyLocal and 10) and an operator (the equal comparison operator). It will return "L" when MyLocal is numeric, "U" (for undefined) in every other case, including when MyLocal is not a valid field or variable name.
If the expression fails to resolve properly, TYPE() will return "U". In fact, I use TYPE() whenever an undefined result may be returned, and VARTYPE() in other cases. TYPE() is completely safe to not raise an error as long as its argument is a string.
A final point: TYPE() may receive an extra numeric parameter holding the value 1, to indicate that the code is querying for an array. In this case, TYPE() will return "A" if the character expression represents an array, "U" in every other situation (even if the expression evaluates successfully).