Community articleUFLCreate 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 creates a new formNodeP and attaches it to the form hierarchy at the indicated location. Once created, the type and identifier of a formNodeP cannot be changed.
Note that you can also use UFLSetLiteralByRefEx to create a formNodeP at the option level and below. Using UFLSetLiteralByRefEx is often easier and faster than using UFLCreate.

Function

   formNodeP UFLCreate(
      formNodeP aNode,
      r_short where,
      r_charP theType,
      r_charP theLiteral,
      r_charP theFormula,
      r_charP theIdentifier);


Parameters

Table 1. create parameters
ExpressionTypeDescription
aNodeformNodePThe new formNodeP is placed in the form hierarchy in relation to this node. If NULL, this creates a new formNodeP hierarchy (a new form)
wherer_short
A constant that describes the location, in relation to the parameter aNode, in which the new node should be placed:
UFL_APPEND_CHILD — adds the new node as the last child of aNode.
UFL_AFTER_SIBLING — adds the new node as a sibling of aNode, placing it immediately after that node.
UFL_BEFORE_SIBLING — adds the new node as a sibling of aNode, placing it immediately before that node.
Note: If the parameter aNode is NULL, then this parameter should be set to 0.
theTyper_charPThe type to assign to the formNodeP being created. This is only necessary for page and item nodes. Use NULL for all other nodes. The type cannot be changed after the node has been created.
If you are creating a non-XFDL node, you must also include the namespace that the node should belong to, as shown:
   <namespace prefix>:<type>

For example:
   custom:myItem

If you do not provide a namespace, the function will assign the default namespace for the form.
theLiteralr_charPThe literal to assign to this formNodeP. NULL is valid.
theFormular_charPThe formula to assign to this formNodeP. NULL is valid.
theIdentifierr_charPThe identifier to assign to this formNodeP. The identifier cannot be changed after the node has been created. NULL is valid.
If you are creating an option or argument level node, this must also include the namespace the node should belong to. Use the following format:
   <namespace prefix>:<type>

For example:
   custom:myOption

If you do not provide a namespace, the function will assign the default namespace for the form.


Returns

The new formNodeP.

Example

In the following example, UFLDereferenceEx is used to locate a specific node. UFLCreate is then used to create a sibling to that node and to place it directly after that node in the form structure.
   r_error addPicLabel(formNodeP form) 
   { 
   formNodeP tempNode;
 
      if ((tempNode = UFLDereferenceEx(form, NULL, "PAGE1.GENDERLABEL", 0,
         UFL_ITEM_REFERENCE, NULL)) == NULL)
      { 
         fprintf(stderr, "Could not locate GENDERLABEL node.\n"); 
         return(NOTOK); 
      } 
      if((tempNode = UFLCreate(tempNode, UFL_AFTER_SIBLING, "label", NULL,
         NULL, "PICLABEL")) == NULL) 
      { 
         fprintf(stderr, "Could not create PICLABEL node.\n"); 
         return(NOTOK); 
      } 
      return(OK);
   }


Parent topic:
XFDL functions