Community articleReadForm function
Added by IBM contributorIBM on May 2, 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.


This function reads a form into memory from a specified file.


   Function ReadForm(
      theFilePath As String, 
      flags As Long
      ) As IFormNodeP


theFilePathStringThe path to the source file on the local disk.
flagsLong0 — no special behavior.
UFL_SERVER_SPEED_FLAGS — This setting significantly improves server processing times. It does that by turning off the following features: computes, automatic formatting, duplicate sid detection, XForms processing, write relevant, the event model, and relative page and item tags (for example, itemprevious, itemnext, and so on).
Note that this setting does not respect XForms relevance.
UFL_SERVER_SPEED_FLAGS_WITH_XFORMS — This setting significantly improves server processing times in the same manner as UFL_SERVER_SPEED_FLAGS, but it does not turn off XForms processing, and it respects XForms relevance.
The remaining flags cause special behaviors. If using multiple flags, combine them using a bitwise OR, AND, or NOT. For example:

UFL_AUTOCOMPUTE_OFF — Reads the form into memory, but disables the compute system so that no computes are evaluated.
UFL_AUTOCREATE_CONTROLLED_OFF — Reads the form into memory, but disables the creation of all options that are maintained only in memory (for example, itemnext, itemprevious, pagenext, pageprevious, and so on).
UFL_AUTOCREATE_FORMATS_OFF — Reads the form into memory, but disables the evaluation of all format options.
UFL_XFORMS_INITIALIZE_ONLY — Turns off UI connection to the XForms model. This flag respects XForms relevance and validity settings, but changes to the XForms model are not reflected in the UI.
UFL_XFORMS_OFF — Turns off XForms processing, including UI connection to the XForms model.


Returns an IFormNodeP that is the root node of the form, or throws an exception if an error occurs.


Duplicate Scope IDs
If a form contains duplicate scope IDs (for example, two items on the same page with the same SID), ReadForm will fail to read the form and will return an error. This enforces correct XFDL syntax, and eliminates certain security risks that exist when duplicate scope IDs appear in signed forms.
Digital Signatures
When a form containing one or more digital signatures is read, the signatures will be verified. The result of the verification is stored in a flag that can be checked by calling GetSignatureVerificationStatus.
Note that this flag is only set by ReadForm, and its value will not be adjusted by changes made to the form after it has been read. This means that calls such as SetLiteralEx may actually break a signature (by changing the value of a signed item), but that this will not adjust the flag's value. To verify a signature after changes have been made to a form, use VerifyAllSignatures.
Server-Side Processing
Using the UFL_SERVER_SPEED_FLAGS setting significantly improves performance during server-side processing. Note that this setting turns XForms processing off. If you need XForms processing to be on, use UFL_SERVER_SPEED_FLAGS_WITH_XFORMS.
If you find that you need some but not all of the functionality of UFL_SERVER_SPEED_FLAGS, you can turn off these flags as shown in the Server-Side Processing usage note, above.
Using UpdateXFormsInstance and ExtractXFormsInstance with UFL_SERVER_SPEED_FLAGS
You can modify an XForms instance with UpdateXFormsInstance when the UFL_SERVER_SPEED_FLAGS flag is used in ReadForm, but because the XForms engine is off, any computed values associated with the updated data are not processed, and changes to bound fields are not processed. Also note that because XForms processing is off, ExtractXFormsInstance might not always return valid data.


In the following example, the function uses ReadForm to load a form into memory and return the root node of the form.
   Function LoadForm(FileName)
      Dim DTK, XFDL, TempForm ' objects
      ' Get a DTK object and initialize the API
      Set DTK = CreateObject("PureEdge.DTK")
      DTK.IFSInitialize "aspApp", "1.0.0", "6.5.0"
      ' Get an XFDL object and read the form from the supplied file
      Set XFDL = CreateObject("PureEdge.xfdl_XFDL")
      Set TempForm = XFDL.ReadForm(FileName, 0)
      ' Return the form
      Set LoadForm = TempForm
   End Function

Parent topic:
XFDL functions