4DQuiz


Object Info Routines View from small screen devices!  

Object Info Routines

The following routines provide the ability to obtain complete information about an object as a whole. To obtain information about individual items within an object, see “Item Info Routines”

OT IsObject version 1

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 ifEnd 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

OT ItemCount version 1

OT ItemCount(inObject {; inTag}) Number

Parameter Type Description

inObject Longint A handle to an object

inTag String Tag of an embedded object

Function result Number The item count

Discussion

OT ItemCount returns the number of top level items in the referenced object. Items in embedded objects are not included in the count.

If inObject is not a valid object handle, an error is generated, OK is set to zero, and zero is returned.

If the tag is not passed or is empty, the count of top level items in the object is returned.

If the tag is passed, is not empty, and is a valid item reference for an embedded object, the count of top level items in the embedded object is returned.

Otherwise an error is generated, OK is set to zero, and zero is returned.

See Also

OT IsObject, OT IsEmbedded

OT ObjectSize version 1

OT ObjectSize(inObject) Number

Parameter Type Description

inObject Longint A handle to an object

Function result Number The total size of the object in bytes

Discussion

OT ObjectSize returns the total size of an object in memory. If inObject is not a valid object handle, an error is generated, OK is set to zero, and zero is returned.

See Also

OT GetAllProperties , OT GetItemProperties



Topics of Interest
Command Reference
Item Info Routines
Object Utility Routines
 

Published date: Fri, 14 Jul 2006 17:54:58 GMT   → View XML Version

Edit this page now

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