Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VARTYPE() vs PEMSTATUS()
Message
From
10/01/2009 11:29:12
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01372210
Message ID:
01372545
Views:
19
>>>>>If you need to check for a property or a method, use pemstatus. Otherwise you may check with vartype. It all depends on what you're trying to do.
>>>>
>>>>Syntax aside, obviously I'm checking to see if an object exists. Just an exacto knife and a pencil, Nadya.
>>>
>>>In this case, I would try to use GETPEM() or check for type('myObject.myOtherObject.Name') = 'C'
>>
>>Did you mean 'O' instead of 'C' ? I'm checking for an object.
>
>No, I meant 'C' because I'm checking for a name of the object - property that exists for all objects. This is what I use and Ian too. It handles a case of object already destroyed (null).

All objects? Well, not all. There are two exceptions: empty object, and scatter name object. These may have a name property by accident, of course - addproperty(oEmpty, "Name", 42) would throw your test completely, and even a scatter name object may be scattered from a cursor which had a name field (which could be a logical or a date or whatever - there are weird table designs out there...).

But if we're looking for controls, as Jay is probably doing (judging by his other posts these weeks), then checking for type('myObject.myOtherObject.Name') = 'C' is a true and tried technique which tests for both existence and isnull() at once.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform