Community articleUFLGetNodeType function
Added by IBM contributorIBM on July 26, 2013
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Description

This function returns the type for a node (for example, page, item, option, and array). This allows you to quickly determine the type of node you are working with and what depth you are at in the node hierarchy.

Function

   r_error UFLGetNodeType(
      formNodeP theFormNode,
      r_u_long *theType
   );


Parameters

Table 1. Function parameters
ExpressionTypeDescription
theFormNodeformNodePThe node to get the type for.
theTyper_u_long*A pointer that will contain the node's type. This will be one of the following constants:
UFL_FORM — The root node of the form.
UFL_PAGE — A page level node.
UFL_ITEM — An item level node.
UFL_OPTION — An option level node.
UFL_ARRAY — An argument level node, such as an array element.


Returns

OK on success or an error code on failure.

Example

The following function receives a node below the page level and uses UFLGetParent to ascend the hierarchy until it reaches a page node, as detected by UFLGetNodeType.
   formNodeP ascendToPage(formNodeP theNode)
   {
   r_u_long theType;
 
      /* Get the type of the node. */
 
      if (UFLGetNodeType(theNode, &theType) != OK)
      {
         fprintf(stderr, "Could not get node type.");
         return(NULL);
      }
 
      /* While the node is not NULL and the node is not a page node,
         get the parent of the node. */
 
      while ((theNode != NULL) && (theType != UFL_PAGE))
      {
 
         /* Get the parent node. */
 
         theNode = UFLGetParent(theNode);
 
         /* Get the type of the node. */
 
         if (theNode != NULL)
         {
            if (UFLGetNodeType(theNode, &theType) != OK)
            {
               fprintf(stderr, "Could not get node type.");
               return(NULL);
            }
         }
      }
      return(theNode);
   }


Parent topic:
FormNodeP functions