Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Field exists?
Message
From
13/01/2008 17:07:16
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01281442
Message ID:
01281489
Views:
8
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform