Community articleRetrieving A Value from a Form
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

Once you have set up and initialized your application with the API and loaded a form into memory, your application is ready to start working with the form. The following code uses UFLGetLiteralByRefEx to get a specific value from the form:
Retrieve the birth date indicated on the form by implementing the getBirthDate function. getBirthDate will make three calls to UFLGetLiteralByRefEx.
   #ifndef OLD_STYLE_PARAMS
      r_short getBirthDate(formNodeP form, int *birYear, *birMonth, 
      int *birDay)
   #else
      r_short getBirthDate(form, birYear, birMonth, birDay)
      formNodeP form;
      int *birYear;
      int *birMonth;
      int *birDay;
   #endif
   {
   r_charP temp=NULL;
   r_short error;
 
   /* Call UFLGetLiteralByRefEx to get the literal information for the
      'PAGE1.BIRTHYEAR.value' node. An error code will be returned if there
      is a problem. */
 
      error = UFLGetLiteralByRefEx(form, NULL, "PAGE1.BIRTHYEAR.value", 0, 
         NULL, NULL, &temp);
      if (error != OK)
      {
         reportError("UFLGetLiteralByRefEx error %hd.\n", error);
         return(NOTOK);
      }
 
      /* If a literal value was returned, convert it into an integer value.
      Otherwise, indicate that no value was entered into the field, and exit
      the program. */
 
      if (temp != NULL)
         *birYear = atoi((char *)temp);
      else
      {
         reportError("The birth year was not entered.\n",0 );
         return(NOTOK);
      }
 
      /* Call UFLGetLiteralByRefEx to get the literal information for the
      'PAGE1.BIRTHMONTH.value' node. An error code will be returned if there
      is a problem. */
 
      error = UFLGetLiteralByRefEx (form, NULL, "PAGE1.BIRTHMONTH.value", 
         0, NULL, NULL, &temp);
      if (error != OK)
      {
         reportError("UFLGetLiteralByRefEx error %hd.\n", error);
         return(NOTOK);
      }
 
   /* If a literal value was returned, convert it into an integer value.
      Otherwise, indicate that no value was entered into the field, and exit
      the program. */
 
      if (temp != NULL)
         *birMonth = atoi((char *)temp);
      else
      {
         reportError("The birth month was not entered.\n",0 );
         return(NOTOK);
      }
 
   /* Call UFLGetLiteralByRefEx to get the literal information for the
      'PAGE1.BIRTHDAY.value' node. An error code will be returned if there is
      a problem. */
 
      error = UFLGetLiteralByRefEx(form, NULL, "PAGE1.BIRTHDAY.value", 0, 
         NULL, NULL, &temp);
      if (error != OK)
      {
         reportError("UFLGetLiteralByRefEx error %hd.\n", error);
         return(NOTOK);
      }
 
   /* If a literal value was returned, convert it into an integer value.
      Otherwise, indicate that no value was entered into the field, and exit
      the program. */
 
      if (temp != NULL)
         *birDay = atoi((char *)temp);
      else
      {
         reportError("The birth day was not entered.\n", 0);
         return(NOTOK);
      }
      return(OK);
   }


Previous topic:
Loading a Form