Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Vartype with tables
Message
From
27/12/2007 08:47:29
 
 
To
26/12/2007 15:33:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01277433
Message ID:
01277722
Views:
20
>>>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
>
>Tamar,
>But I don't understand why would
>
>
?vartype("mytable.myfield")="U"
error. There is nothing to fail there.
>It doesn't error for me and correctly displays .F. Do you all get error and not me?

No, VARTYPE("MyTable.MyField") returns "C" because it evaluates the expression and notes that it's character.

However, VARTYPE(MyTable.MyField) errors if there's no table open with an alias of MyTable (and, of course, no object variable called MyTable.

The key issue with VARTYPE() is that it's really meant to be used when you know the expression exists and just want to know the type. When it was first added, there was no case where it returned "U". That was a later addition.

Tamar
Previous
Reply
Map
View

Click here to load this message in the networking platform