Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Vartype with tables
Message
De
26/12/2007 13:16:42
 
 
À
26/12/2007 09:42:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01277433
Message ID:
01277576
Vues:
21
>>>I can use type for if there is a field in table:
>>>
>>>
?type("mytable.myfield")="U"
>>>
>>>but with vartype
>>>
>>>
?vartype("mytable.myfield")="U"
>>>
>>>is generates variable not found. Isn't that a bug?
>>
>>Here's what we said in HackFox about this:
>>
>>"Because VARTYPE() explicitly passes the expression to test as a parameter, it fails if an expression cannot be evaluated, causing an error 12, "Variable not found"—you'll still want to use TYPE() to check if a variable exists."
>>
>>Tamar
>
>hi Tamar,
>
>That is not exactly true
>
>?vartype(tamar) && U
>
>obj = createobject('relation')
>?vartype(obj.tamar) && U
>?vartype(obj.BackColor) && U
>
>&& Existing properties that are being hidden/protected generate an error
>?vartype(obj.left) && Error, as with top, height, width
>
>obj = createobject('www')
>?vartype(obj.qqq)  && error
>
>
>define class www as relation
>	protected qqq
>	qqq = 0
>enddefine
>
Yeah, should have said something about that. That was a change at some point. Earlier versions of VFP errored if the variable didn't exist. That was part of what made VarType() so much faster than Type().

A good rule of thumb is to use VarType() only on expressions where you could use EVAL().

Tamar
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform