Precedence of variable expansion
This topic refers to the expansion of variables in the COPIAFACTS engine only. This includes the expansion of variables in the dynamic link libraries (DLLs) which process e-mail operations (CF8EMAIL), SMS operations (CF8SMSxx) and graphical cover sheets (CF8GCOVER). These DLLs also have access to all engine variables. Engine variables can also be accessed from customer-written DLLs.
The COPIAFACTS engine attempts to expands variables in the following sequence, each time it comes to an 'expansion character' (@ or `, as appropriate) in the text string to be expanded. Note that values which themselves contain the 'expansion character' are not usually expanded: but see recursive variables.
1. System Read Only (SRO) and Read-Write (SRW) Variables
The table of fixed variable names is scanned first. If the value to be expanded is found it is always expanded. Take care that you do not define a variable which has a system variable name as an initial substring. For example if you had defined a variable:
$set_var titlestring "My title string"
then the @titlestring would not be expanded as expected because the system variable @TITLE would be processed first.
2. Variables Defined and Set in FS Files, Infobox Files, and User Profile/Property Files
The main rule here is last-in-first-out. A later definition or assignment overrides an earlier one:
•For inbound calls, and IVR, USR file variables are overridden by variables of the same name set in infobox scripting, or filled from DTMF entry.
•For outbound calls, USR file variables are loaded first, followed by FS file variables, followed by variables set in infobox pre- or post-process scripting.
•For job instance property files (UJP), the file will have been constructed so that variable definitions appear in the sequence system - owner - jobtype - instance. This ensures that when the file is loaded, the later values correctly override the earlier ones.
The current set of these dynamic variables is scanned at the time the variable is to be expanded. Normally, the longest possible name found in the text is expanded, not the first match. For example if you define infobox variables:
$set_var myvar1 "First Value"
$set_var myvar10 "Tenth Value"
then after this .IIF file has been selected and processed, when you write @myvar10 it will be expanded as "Tenth Value" and not as "First Value0".
There is one exception to the rules for expanding variable names. Variable expansions of the form @MEMOx, @BCFx or @BCHx (with the specific names MEMO, BCF and BCH) are processed specially, and only an exact match is expanded. Thus if you have defined MEMO3 in an FS file, but have not defined MEMO30, then writing @MEMO30 in a cover sheet template file will not cause the value of MEMO3 followed by a zero to be expanded. This feature allows you to include a large number of @MEMOx expansions in a cover sheet template file, and have them correctly expand to blank if a smaller number of $var_def MEMOx commands have been created in the FS file.
In general, we recommend never using variable names where one name is an initial substring of another. For example, if you define WORKA and WORKB, do not also define WORK as a variable. Although the system will usually sort things out (as with myvar1 and myvar10 above) this practice can make assignments in infobox logic more difficult to understand and debug.
3. Variables Defined in the Configuration File
The $var_def command can be used in the configuration file to assign default values for IIF and FS variables, or as a convenient way to set semi-permanent global values.
4. Environment Variables
Any environment variable may be referenced using the @ syntax. In this case the extent of the variable name is delimited by a whitespace or punctuation character, so that for example "@TEMPORARY" is not expanded from the environment variable TEMP. Pseudo-environment variables may also be set using the $environment configuration command.
If no valid variable name is found in the above categories, the @ and the variable name, delimited by white space or a punctuation character, are deleted from the text.