Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Field exists?
Message
De
13/01/2008 17:07:16
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01281442
Message ID:
01281489
Vues:
9
>thank you but...
>
>**********************************
>USE config2
>IF VARTYPE( config2.version ) <> "U"
>
>= MESSAGEBOX("field exist")
>
> else
>= MESSAGEBOX("field does not exist")
>
>endif
>
>
>
>*************************************
>
>If field "version" does not existe it does not display
>the messagebox above
>
>It displays variable not found instead

Moises:

While VARTYPE() is somewhat (trivially) faster than TYPE(), it is also more error-prone. Since it explicitly passes (in your case) the field name as a parameter, if the field name doesn't exist, it will cause "Variable not found" -error. You should only use VARTYPE() if you know that the variable/field name exists, which in many cases totally defeats the purpose.

Since I'm generally trying to keep my memory as uncluttered as possible of all kinds of trivial information, I ALWAYS use TYPE(), because it always returns the variable type or "U" as unknown, whether the variable/field name exists or not. Speed issue for me (in this case a fraction of a second difference) is of trivial concern, since I have never ever had a situation where I would call TYPE() in a huge loop where it would make a noticeable difference.

So, I recommend forgetting that VARTYPE() even exists, because sooner or later you are going to get an error with it. Guaranteed.

Pertti
Pertti Karjalainen
Product Manager
Northern Lights Software
Fairfax, CA USA
www.northernlightssoftware.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform