ChildByIndex - cObject

Can be used to iterate the direct children of an object

Type: Function

Return Data Type: Handle

Parameters: Integer iIndex

iIndexChild object index

Return Value

Function ChildByIndex Integer iIndex Returns Handle

Call: Get ChildByIndex iIndex to HandleVariable


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.


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