$collSize

Get the number of Struct nodes in the collection.

Struct->$collSize

Return Values

The value returned by $collSize depends on whether Struct refers to a single Struct or to multiple Structs.

Return Values

Return Value

Meaning

>1

Number of members in the collection

1

StructVariable refers to a single Struct node or a Struct leaf

0

StructVariable does not refer to a Struct

 

Values of $procerror Commonly Returned Following $collsize

Value

Error Constant

Meaning

-1155

USTRUCTERR_MEMBER_NOT_FOUND

Struct member not found

-1157

USTRUCTERR_ILLEGAL_MEMBER_TYPE

Not a valid struct member type

Description

The $collSize function is intended for use with a struct variable or parameter that refers to multiple Structs. If it refers to only a one Struct, you can use the $memberCount Struct function. In this case, the expression StructVariable->$memberCount evaluates to the same value as StructVariable->*->$collSize.

Using the Collection Size

The collection size can be used when you need to iteratively process the members of a Struct. For example:

vTotalStructs = pStruct->$collsize
if (vTotalStructs > 1) 
    i = 1
    while (i <= vTotalStructs)
      ;do something
      i = i + 1
    endwhile
 else
   ;do something else
endif
History

Version

Change

9.5.01

Introduced

9.6.02

Can return a value of 0

Related Topics