Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VARTYPE vs TYPE with Parent property
Message
De
25/07/2002 11:23:13
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
 
 
À
24/07/2002 15:52:33
Beth Wetherbee
Virginia Beach Public Schools
Virginia Beach, Virginie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00682266
Message ID:
00682528
Vues:
23
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform