Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining existence of an object
Message
From
10/08/1999 08:40:21
 
 
To
09/08/1999 23:52:42
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00251780
Message ID:
00251908
Views:
14
Not so short... if the object you are testing is the child of another object, or your only reference to it is through the property of another object, you won't want to use VARTYPE at all, because the parent object's non-existence will break the code. This also gets back to the MS team's stance that this is not what VARTYPE is for. If you need to check the existence of a variable, use TYPE. It is slower, but still not slow by any measure of the word (1000000 iterations took about 4 seconds on my machine, where VARTYPE took about 1). It is just safer.


>Sooo...to make a long story short:
>
>IF VARTYPE(oMyObject) = "O" && It's Allliiive....
>ELSE && It ain't no object or it's a daid object
>ENDIF
>
>:-D
>
>
>>Right you are. I was surpirised to find out this is true. Still learnin'.
>>
>>>It was my understanding that VARTYPE would only pass an 'O' if the variable was a living object. If VARTYPE were to classify a dead object it would return an 'X' because the variable was NULL.
>>>
>>>Glenn
>>>
>>>>I am sure you know John, but hust to clarify-
>>>>
>>>>the test below will determine if the variable named oMyObject is of the object type, but does not test to see if it actually references a living object. To do that, you either need to check the type of one of the object's properties (usually "name"), or, after testing the type, checking for ISNULL(oMyObject)
>>>>
>>>>>Hi Jim,
>>>>>
>>>>>IF VARTYPE(oMyObject) = "O" && It's an object
>>>>>IF VARTYPE(oMyObject) = "U" && It ain't nothing yet
>>>>>
>>>>>>I am using the addobject method to add an object to my form from a custom container class. Once it is created, how can test to see if it already exists?
>>>>>>
>>>>>>Thanks
>>>>>>Jim Oswald
>>>>>>joswald@innova.net
Erik Moore
Clientelligence
Previous
Reply
Map
View

Click here to load this message in the networking platform