Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VARTYPE vs TYPE with Parent property
Message
From
25/07/2002 11:23:13
 
 
To
24/07/2002 15:52:33
Beth Wetherbee
Virginia Beach Public Schools
Virginia Beach, Virginia, United States
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00682266
Message ID:
00682528
Views:
24
Beth-

>?VARTYPE(ox.Parent) && blows the 'Parent does not exist' error
>?TYPE('ox.Parent') && returns 'U'

I agree with Çetin that TYPE() is safer in this case. My rule of thumb is this. If in my code I'm sure I'll have a variable, but am not sure what type it is, then I'll use VARTYPE(). If there is a good chance the variable doesn't exist yet (as in your case), then I use TYPE(). It's simplistic but I've found it to be reliable.

To add a note to Çetin's post. For objects, one should be careful about checking just whether their type is "O". It's safer to check a property, say "Name", if it will have one, or add !ISNULL() to the check.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform