4DQuiz


OT IsObject View from small screen devices!  

OT IsObject(inObject) Longint




Parameter Type    Description

inObject Longint    A handle to an object

Function result Longint    → 1 if inObject is an ObjectTools ← object handle, 0 if not

Discussion

To test whether a given Longint value is a valid object handle, use OT IsObject. If inObject points to a valid object, 1 is returned. If inObject is zero or points to some other type of object, zero is returned.

While it is possible to construct a BLOB that would fool ObjectTools into thinking it was a object, this is extremely unlikely.

All ObjectTools methods check the validity of the object handle passed in to prevent truly nasty things from happening. Unless you are unsure about the contents of a variable or field passed to ObjectTools as a object handle, there is no need to call OT IsObject first.

Example

If you try to retrieve an embedded object from another object and it does not exist, a null object handle is returned. In that case you would want to test the result as shown in the example below.

C_STRING(255;$tag) $tag:=Request("Item tag:")

If ((OK=1) & (Length($tag)>0) C_LONGINT($embedded) $embedded:=OT GetObject (stMyObject;$tag) `$tag may not be valid!

If (OT IsObject ($embedded)) `Do something with the object End if End if

The above example assumes that the requested tag is valid and tries to get the embedded object before checking the tag’s validity. Another approach would be to check the tag first by using OT ItemExists.

See Also

OT ItemExists


Topics of Interest
OT New
OT GetObject
Import/Export Routines
OT ItemCount
OT Copy
OT IsObject,OT Clear
OT ObjectToNewBLOB
Object Info Routines
Creation and Destruction Routines
 

Published date: Fri, 14 Jul 2006 22:27:20 GMT   → View XML Version

Edit this page now

© 2005 - 2006 4dquiz.com, All trademarks accepted. All Rights Reserved!
Site Index