Community articleUFLAttachPage
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

Forces one or more pages to be loaded into memory.

Description

Use attachPage to ensure that the entire form and all of its pages are loaded into memory and are accessible to API functions. Forms that use the XFDL pageloading option do not always have all pages of the form loaded into memory. Although some functions might appear to work properly on pages that are not loaded, the results are not accurate. For example, UFLCheckValidFormats will not report errors from pages that are not loaded, and you cannot print pages that are not loaded.

It is safe to call UFLAttachPage on pages that are already loaded. It is also safe to call UFLAttachPage on forms that do not use the XFDL pageloading option.

Function

   void UFLAttachPage(
      r_charP pageSID
   );


Parameters

Table 1. Function parameters
ExpressionTypeDescription
pageSIDr_charPThe sid of the page to attach, or NULL to attach all pages.


Returns

Nothing.

Example

The following example loads in a form, calls UFLAttachPage to ensure that the entire form and all of its pages are loaded into memory, then calls UFLCheckValidFormats.

r_error validateForm()
{
  formNodeP *theForm;
  formNodeP *invalidItems;
  r_long invalidItemsSize;
 
  /* read in a form that has <pageloading> enabled  */
  if ((*theForm = UFLReadForm("sample.xfdl", 0)) == NULL)
  {
    fprintf(stderr, "Could not load form.\n");
    return(NOTOK);
  }
 
  /* attach all pages before calling UFLCheckValidFormats */
  UFLAttachPage(NULL);
 
  /* call UFLCheckValidFormats */
  UFLCheckValidFormats(theForm, &invalidItems, &invalidItemsSize);
  if (invalidItemsSize == 0)
  {
    printf("All items in the form have correctly formatted values. \n");
  }
  else
  {
    printf("One or more items in the form have a non valid format. \n");
    pe_free(invalidItems);
    return(NOTOK);
  }
 
  UFLDestroy(theForm);
 
}


Parent topic: FormNodeP functions