$isLeaf

Checks whether a Struct member is an end point of the Struct tree.

Struct->$isLeaf

Return Values

Return Values

Return Value

Meaning

0

Struct refers to a nested Struct

1

Struct refers to Struct leaf.

Values of $procerror Commonly Returned Following Struct Functions

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

A leaf is the logical endpoint in a tree. All scalar Struct members are leaves in the Struct tree, but the reverse is not always true. For more information, see Struct Leaves.

If a Struct is a scalar Struct, or if it has a value and no sub nodes, it is a leaf and $isLeaf returns 1 (true).

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
  1.  If vStruct refers to the node of a nested Struct.
  2.  Get the number of members in the node.
  3.  Put the name of each member in the message frame.
History

Version

Change

9.5.01

Introduced

Related Topics