$memberCount
Get the number of members in a Struct.
Struct->$memberCount
Return Values
The value returned by $memberCount depends on whether Struct refers to a single Struct or to multiple Structs.
Return Value |
Meaning |
---|---|
|
Struct has no members |
>= |
Number of members in the Struct. |
|
Struct has 1 member, or Struct has 1 member and 1 scalar member that holds the value of the Struct itself (only applicable for mixed content). |
|
Struct refers to a collection of Structs, or is not a Struct |
Value |
Error Constant |
Meaning |
---|---|---|
-84
|
UACTERR_NO_OBJECT
|
Struct refers to zero Structs |
-1151
|
USTRUCTERR_NO_COMMON_CHARACTERISTICS
|
Collection of Structs that do not share a common parent or the specified characteristic |
-1157
|
USTRUCTERR_ILLEGAL_MEMBER_TYPE
|
Not a valid Struct member type |
Description
The $memberCount function is intended for use with a struct variable or parameter that refers to a single Struct.
The value returned by $memberCount does not include annotations; these can be accessed using $tags.
If Struct refers to more than one Struct, you can use the $collSize function to get the number of Structs in the collection.
Check for Struct Nodes before Iterating
You can use $isLeaf to check whether a member is a nested Struct, before using $membercount. For example:
if (!vStruct->$isLeaf) If vStruct refers to the node of a nested Struct. i = 1 while (i <= vStruct->$membercount) Get the number of members in the node. putmess "Member %%I have name %%(vStruct->*{i}->$name)" Put the name of each member in the message frame. i = i + 1 endwhile endif
Version |
Change |
---|---|
9.5.01 |
Introduced |