Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Vartype function fixed in SP3...
Message
From
06/07/1999 19:12:08
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00237900
Message ID:
00238014
Views:
17
>>Mark,
>>
>>I believe the problem is when vartype() is asked to determine the type of a property for a non-existant object. I believe that it was said that it is by design because vartype() was added to be faster than Type() and therefore is doesn't do the checking the same way and it therefore cannot trap the non-existant object.
>>
>>All fo this is from memory, so it may not be correct.
>
>I created a form object from the command window, and tested it against an undefined form property [? Vartype(oForm.Test)]. It did return U. I have not had a chance to test this under runtime only, but I will later this evening.
>
>Now, if I set oForm = .null., and test for oForm.Anything, I get an error returned. But Vartype(oForm) will return X at that point.
>
>Or am I missing your point?

No, this is the point. There was some discussion a while back (soon after VFP 6 beta was released) about this. Developers complained that VARTYPE() gave an error with an undefined variable, and the VFP team's sentiment was "Yeah, that's what it's supposed to do- just like any other function that you pass a variable that doesn't exist. If you don't know that a variable exists, use TYPE() instead".

But apparently they got enough complaints that they added an internal error check (to the detriment of the efficiency of the function) that would return "U" instead of throwing an error. But the internal error check only checked for the most precise variable, and still assumed that the objects in the containership hierarchy (if the variable was a property, or a reference to a contained object) were defined.

IMHO, this is not a bug, and would only surface if the function was being misused. Any further error checking in the function would cost time, and move towards defeating the spirit of the function.

BTW, the error checking is not new to SP3.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform