Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Declared Variable or not
Message
De
15/07/2000 01:43:12
 
 
À
14/07/2000 16:48:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00392683
Message ID:
00392830
Vues:
8
>Is there a way to check to see if a variable exists or not. For instance, if var1 exists, do whatever, but if not, declare it and then do it.
>

IF Vartype(var1) $ 'UX' && U = undefined, X is defined but NULL

>Same question goes for arrays and objects. If form exists, do something... if not, do something else or create it.

IF TYPE('Var1[1]') # 'U' && Array exists

IF VARTYPE(oObjRef) = 'O' AND NOT ISNULL(oObjecRef) && object exists

Forms are a bit different; in general, it's best to spin through the _Screen.Forms collection trying to find your form, since there may not be a usable independent object reference in scope for a form even when the form is there; the _Screen.Forms collection has a member for each Form presently instantiated, even if no other variable that refers to the Form is presently in scope and addressible.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform