Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function to check variable type
Message
De
15/02/2001 14:42:26
 
 
À
15/02/2001 14:30:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00476059
Message ID:
00476434
Vues:
25
>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.
m.field = 1
Table.field contains "Test"

SELECT table
? TYPE("m.field")     && N
? TYPE("field")       && C
? TYPE("table.field") && C

SELECT 0
? TYPE("m.field")     && N
? TYPE("field")       && N
? TYPE("table.field") && C
>
>>>Is there a quick function to check if a variable is a field from a table or a memory variable ?
>>>
>>>
>>>Thanks in advance.
>>
>>
>>IF TYPE('table.field')<>"U"
>>  *
>>  * It's a table field
>>  *
>>ELSE
>>  IF TYPE('field')<>"U"
>>    *
>>    * it's a memvar
>>    *
>>  ELSE
>>    *
>>    * no such animal exists
>>    *
>>  ENDIF
>>ENDIF
>>
Fred
Microsoft Visual FoxPro MVP

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

Click here to load this message in the networking platform