Community articleSetting a Value in a Form
Added by IBM contributorIBM on May 3, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.



Once a form is loaded into memory, a developer can set the values associated with any of the item or option nodes located in the form by calling UFLSetLiteralByRefEx.
Change the values of hidden fields in the original form. These hidden fields are arguments for a compute in the SHOWAGE label that calculates the user's age.
   #ifndef OLD_STYLE_PARAMS
      r_short setBirthDate(formNodeP form, int birYear, int birMonth, 
      int birDay)
   #else
   r_short setBirthDate(form, birYear, birMonth, birDay)
      formNodeP form;
      int birYear;
      int birMonth;
      int birDay;
   #endif
   {
   r_short error;
   char *temp [100];
 
   /* Convert the int to a r_charP and set the value of PAGE1.HIDDENYEAR.value */
 
      sprintf(temp, "%d", birYear);
 
   /* Call UFLSetLiteralByRefEx. The parameters are:
      1. form : the formNodeP to use as the starting point for the search.
      2. XFDL : the scheme used to write the reference parameter.
      3. PAGE1.HIDDENYEAR.value : the reference to the node.
      3. 0 : must be zero.
      4. NULL : use the ANSI character set.
      5. NULL : do not use a namespace node.
      6. temp : the value to assign to the literal.
      An error is returned if there is a problem. */
 
      error = UFLSetLiteralByRefEx(form, NULL, "PAGE1.HIDDENYEAR.value", 
         0, NULL, NULL, (r_charP)temp);
      if(error!= OK)
      {
         reportError("UFLSetLiteralByRefEx error%hd.\n", error);
         return(NOTOK);
      }
 
   /* Convert the int to an r_charP and set the value of
      PAGE1.HIDDENMONTH.value*/
 
      sprintf(temp, "%d", birMonth);
      error = UFLSetLiteralByRefEx(form, NULL, "PAGE1.HIDDENMONTH.value", 
         0, NULL, NULL, (r_charP)temp);
      if(error!= OK)
      {
         reportError("UFLSetLiteralByRefEx error%hd.\n", error);
         return(NOTOK);
      }
 
   /* Convert the int to an r_charP and set the value of PAGE1.HIDDENDAY.value */
 
      sprintf(temp, "%d", birDay);
      error = UFLSetLiteralByRefEx(form, NULL, "PAGE1.HIDDENDAY.value", 0,
         NULL, NULL, (r_charP)temp);
      if(error!= OK)
      {
         reportError("UFLSetLiteralByRefEx error%hd.\n", error);
         return(NOTOK);
      }
      return(OK);
   }