Skip to content

ChildByIndex - cObject

Can be used to iterate the direct children of an object

Type: Function
Return Data Type: Handle

Parameters

Parameter Type Description
iIndex Integer Child object index

Syntax

Function ChildByIndex Integer iIndex Returns Handle

Call Example

Get ChildByIndex iIndex to HandleVariable

Description

ChildByIndex is a function that can be used to iterate the direct children of an object. It allows for a certain amount of reflection into a dynamic object structure. Together with IsObjectOfClass, dynamic behaviours can be added to Applications.

Note that if Child_Count is exceeded, it will return handle 0 which is equivalent to a null-object. As such, it is recommended to always guard using Child_Count. The function does not throw any error.

Sample

Handle hoParent hoChild
Integer iIndex

For iIndex from 0 to (Child_Count(hoParent) - 1)
    Get ChildByIndex of hoParent iIndex to hoChild
    If (IsObjectOfClass(hoChild, RefClass(cWebObject))) Begin
        Send ShowInfoBox (SFormat("""
            %1, is a WebObject.
            """, Object_Label(hoChild)))
    End
Loop