Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function to check variable type
Message
De
15/02/2001 14:57:37
 
 
À
15/02/2001 14:49:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00476059
Message ID:
00476443
Vues:
29
>>>That requires knowledge ofthe tablename. What if you have 50 tables open?
>>>If you test
>>>if type('m.field')="U" and type('field')<>'U'
>>> it must be as table field
>>>endif

>>>
>>>
>>>
>>>Peter
>>>
>>
>>Testing for the "M." variable name works without having to know the table name. But using TYPE() without a table name always seems to check for a memory variable reference, not a field reference, if the table is not the current workarea. To check for a field reference you must specify the table.field to tell, or make sure that the table is the currently selected one.
>
>
>I don't understand what you are telling me. I understood the question to be to find out if a given variable is based in memory or a table. Since the table name is not necessarily known I would check for the memory variable first as it is in my example. If it is not a memory variable but also not undefined it has to be table based.

>
>I am not sure if you are agreeing or disagreeing.
>
>Peter

In my example, always using the "m." prefix will definitely tell you it's a memory variable or not. Without ANY kind of prefix, it will depend on if the table is selected or not. If there is no memory variable and the table is not currently selected, then TYPE("field") will return "U", and if the table is selected, TYPE("field") will return the type of the field (if it was a memory variable). I had to throw that last part in because a memo field will return "C", not "M" for memo, like you would get with AFIELDS(), so it's not really the field type.

In your example above, if the table wasn't current when you did the TYPE(), you still wouldn't know if it existed as a field in the table or not. The same would be true if there was a variable that existed by the same name. The point I'm trying to get across is that in order to be sure what you've got, you must specify a prefix, either "m." or the table "alias.".
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform