5-4-10 Global variables
A global variable is a variable that you can define and use as a valid text-type data parameter value between the VrInit and VrQuit functions.
When you define a global variable, you will be able to share the data output from higher-level applications across multiple forms.
For example, if the value for the company name or company address on a form is directly defined as static text during the form design, all forms on which the company name is printed as static text have to be changed individually if the company name changes.
However, if instead of static text, a field is set which uses a global variable showing the company name, all output data can be changed just by changing the value of the global variable in the upper level application, and you will not need to modify all of the XML form files.
Define a global variable and its initial value
In order to use a global variable in a calculation-formula and edit-formula, first define the global variable. You can set any variable as a global variable. Perform the following procedure to register the initial value of a global variable in the XML form file.
This section describes an example of registering a global variable from the Edit-formula dialog.
Click the Set global variable button in the Edit-formula dialog.
"Edit-formula" dialog
When the Global variable dialog appears, click the Add button.
"Global variable" dialog
Set each item in the Add variable dialog.
In the following example, the variable name is set as "$COMPANY$", the data is set as "ABC Corp." and "No initial value" is selected.
After you have finished configuring the settings, click the OK button.
Specify the variable name and data
Variable name
Type the variable name.
Even if you enter the variable name without enclosing it in "$" (for example, "COMPANY"), "$" will automatically be added before and after the variable name and will be registered as "$COMPANY$".
Data
Set any data as the initial value of the variable.
The data is internally treated as text data. When entering the data, there is no need to enclose it with "" (double quotations), even when specifying text data.
Only enclose it with double quotations if you want to enter the data as a string that will appear enclosed in double quotations, such as "ABC Corp." (displayed including the double-quotes).
In this example, type in ABC Corp. (without double quotations).
No initial value
Used to determine the initial value when printing with the program.
Add a check in the following cases:
When you want to dynamically change the value in the program.
When you are outputting with multiple XML form files that have different values registered to the same global variable name, and you want the second and subsequent XML form files to inherit the global variable value registered in the first XML form file.
Confirm that the variable has been added to the list and click the OK button.
"Global variable" dialog
Reference
If you want to modify a global variable that you have already set, click the Edit button.
However, you cannot change the variable name during editing.
"Edit variable" dialog
When you want to delete a set global variable, click the Delete button.
Set a global variable in the field
This section describes how to set a defined global variable in the calculation-formula and edit-formula of a field.
In the following example, the global variable "$COMPANY$" is set in the edit-formula.
Click the Reference global variable button in the Edit-formula dialog.
"Edit-formula" dialog
Reference
An undefined global variable name can be entered directly in the formula-text field. However, in such cases, you will not be able to register the initial value of the global variable. If you want to register the initial value, return to the previous section "Define a global variable and its initial value" to operate.
The global variable names defined in the XML form file are displayed in a list.
Select the global variable name to use, and then click the Add to formula-text button or double-click the global variable name.
The selected global variable is entered.
The global variables you defined appear
Reference
In a global variable, the value is treated as text-type data.
In order to treat it as numeric data, you must use the VAL function or the NUMVAL function to convert the data.
For examples of settings, see "Specify an undefined global variable name ($<global_variable_name>$)".
Check the output result of a global variable
This section describes the method for checking how the global variable that you specified in the edit-formula will be output.
In the following example, ""Dear " + $COMPANY$" is set in the edit-formula.
Enter ""Dear " + $COMPANY$" in the edit-formula.
It is safer to input the global variable "$COMPANY$" from Reference global variable.
Click the Check results button.
"Edit-formula" dialog
Click the Confirm button.
"ABC Corp." is obtained from the global variable, and the data "Dear ABC Corp." will appear with "Dear" added.
The confirmation result is displayed
The Data field displays the Data value set in the Global variable dialog.
Reference
If you have defined the Data value, its value will appear as the initial value regardless of the setting that determines whether the global variable has an initial value or not.
The setting that determines whether the global variable has an initial value will only be applied when the variable is actually executed from the program.
Reference
The result displays the data that was set when defining the global variable, as a string enclosed in double quotations ("").
For example, if a string such as "Shibuya-ku, Tokyo" which is already enclosed in double quotation marks is set as the data of the global variable $ADDRESS$, ""Shibuya-ku, Tokyo"" will be displayed as the string, with double quotation marks added.
This means that if "Shibuya x-x-x, "+$ADDRESS$ is set in the edit-formula, it is displayed as "Shibuya x-x-x, "Shibuya-ku, Tokyo"" in the Result field. If you want the data to appear as "Shibuya x-x-x, Shibuya-ku, Tokyo", make sure you do not enclose the "Shibuya-ku, Tokyo" string in double quotations when you enter the data value of the global variable.
Specify an undefined global variable name ($<global_variable_name>$)
You may directly enter an undefined global variable name in the formula-text field.
However, you will not be able to register the initial value of the global variable.
In addition, global variable names entered directly in the formula-text field do not appear in the list of global variables.
Format | $<global_variable_name>$ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Settings | In the calculation-formula or edit-formula of the field, define the variable name by enclosing it with "$". When you want to set the initial value data of a global variable and save that data value in the XML form file, you must define the variable from the Set global variable button. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Usage examples | If you want to print multiple XML form files (FORM1 to FORM3) as delivery slips in a single spool, the following two patterns are available for designing the XML form file:
FORM1
FORM2
FORM3
FORM1
FORM2
FORM3
Values set for the properties for each itemReferenceIn a global variable, the value is treated as text-type data. In order to treat it as numeric data, you must use the VAL function or the NUMVAL function to convert the data (see Pattern 2 in the above figure). Differences in the program when you are using the global variable are as follows. The printing result remains the same in either case.
ReferenceIf the company name or address is changed, you must modify the Blue part. When the conversion rate is changed, you must modify the Red part. As you can see from this example, you can use a global variable to reduce the amount of man-hours at the time of the form migration process. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Output result | The output result remains the same in either case.
|