Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking to see if a variable is an array.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00413697
Message ID:
00413758
Vues:
10
>I did apologize when I figured out what he was saying but what about a non-existent variable? It will return ‘U’ as well and it’s not an array.

"but what about a non-existent variable?" - your question implies that you now want to know if a variable that does not exist is an array! This is nonsense.

In VFP one tests for a variable referencing an array by implication. If you simply tried to use ALEN(variable_x) and variable_x is not an array you get a run-time error - trapping this error allows you to determine the nature of variable_x (an array or not an array). Or you can test to see what the data type of the first element is. If it is undefined, then the implication is that the variable is not an array.

If the first element contains any value of any data type, then the variable is an array.

TYPE( "variable_x" ) - might tell you the data type of element one of variabe_x, if it is an array, or it might be telling you the data type of variable_x.

TYPE( "variable_x[1]" ) - is entirely different, if you get anything other than "U" back, then not only do you know the data type of the first element, you also know that you are dealing with an array!

Regards,
Houston.
censored.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform