Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Variable Existence Check
Message
From
30/09/1998 10:44:30
 
 
To
30/09/1998 10:26:32
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00142381
Message ID:
00142390
Views:
18
>I'd like to check if a variable exists. Can someone point me to the function for this?
>
>It would work just like FOUND(), returning a .t. if the var exists and .f. if it does not.
>

Try the TYPE() function; if given the name of a variable (or property, or field) as an ASCII string, it returns a single character designating the data type. An undefined name will return 'U'. So:
Var1 = 0
? 'Created'
IF TYPE('Var1') # 'U'
   ? 'The variable Var1 exists'
ELSE
   ? 'Var1 does not exist'
ENDIF
RELEASE Var1
? 'released'
IF TYPE('Var1') # 'U'
   ? 'The variable Var1 exists'
ELSE
   ? 'Var1 does not exist'
ENDIF
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
Previous
Reply
Map
View

Click here to load this message in the networking platform