Variables

Variable names begin with %% and may contain up to 50 characters but no blanks. They are also case sensitive. The following are examples of different variable names.
%%InvoiceAmount
%%INVOICEAMOUNT
%%Invoice_Amount
All variables are available to all sections of the code. As the diagram below illustrates, if a <FIELD> tag in the control file sets a variable, its value is available to all subsequent steps in the application.

Variables are persistent. Once a variable's value is set, it retains that value until it is reset or the program ends.

For example, assuming %%LAST_BRANCH is not being assigned a value from the document by a <FIELD> tag but %%BRANCH is, the rule code shown in the following example would place a banner page between documents where the branch changes. Field variables are reset for each document.
START:
   %%LAST_BRANCH = ''
DOCUMENT:
   IF %%LAST_BRANCH <> %%BRANCH THEN
       <BANNER> BannerFile BEFORE
       %%LAST_BRANCH = %%BRANCH
   ENDIF
Note: In the above example, %%LAST_BRANCH retains its value from the last time the DOCUMENT: section was run.
You can place variable names within the body of inserts, documents, and banners. If there are variables within these objects, Enrichment can automatically replace the variable name with its value during processing.
For example, if you have $%%amount in the input document and %%amount=10.56 then the text in your output would be $10.56. Likewise if you have %%productname™ in the input document and %%productname=SuperWidget then the text in your output would be SuperWidget™.
Note: Variable substitution is controlled by the <SUBSTITUTE> tag.
Note also that:
  • Variables can contain numeric, string, array, or file name values. There is no typing of variables in Enrichment. Enrichment automatically detects a variable's expected type (integer, string, and so on) based on the context in which you use it.
  • You do not need to declare a variable unless the variable is an array or a global variable. To declare an array or global variable, use the DECLARE function. For more information on arrays, see Arrays.
  • To set a variable to nothing, enter two quotation marks with nothing between them. For example, %%LAST_BRANCH = ''.
  • Delimit variable values that contain spaces with single quotes or double quotes—for example, '908 West 7th St.' or "908 West 7th St." If the value contains quotation marks or apostrophes, you must double the internal quotation marks ('Guy''s Auto Hut' or "Bill''s ""Hi-Fi"" Stereos") or Enrichment assumes they terminate the value.