Array Parameters
See Parameter Example: Using Array to Select Columns and Parameter Example: Using Array to Filter for options using the VI GUI.
Array parameters can be defined using:
- An empty default value. For example:
default = {}, - An inline array consisting of one or more string values. For example:
default = { "red", "green", "blue" }, - A text file containing element values. For example:
default = { current_files },
When using a text file, each line in the file contains a different array element. The number of lines will be equal to the number of elements of the substituted array. The name of the file is specified as the parameter value using either:
-
The -define command-line option when running the Integrator.
- A default string value (instead of an array value).
Example
Instead of an attribute with file names listed in an array:
filenames = {"..\data\mth_01", "..\data\mth_02", "..\data\mth_03"}
the attribute could use an array parameter named current_files:
filename = {‘$(current_files)‘}
where current_files.txt has three records, each with a different file name:
..\data\mth_01 ..\data\mth_02 ..\data\mth_03
The text file for an array parameter will be read when the program accesses the value for that attribute (or subarray). For Integrator, this is done at the beginning of a task. This allows a task to write out a set of column names to a file, and have a subsequent task use an array parameter to refer to the column names in this file.
If an array parameter is used in a script, it must have a value. If the parameter definition does not have a "default" attribute, the parameter must be defined on the command-line with a file name; otherwise, Integrator will give an error. If the file for an array parameter cannot be opened, Integrator will also give an error.
String Arrays with Subarrays
To allow for a parameterized array to appear alongside constant columns in a script, Integrator objects that expect a string array of columns (for example Rotate, Unrotate, Fileout, etc.) will accept arrays that contain a mixture of strings and subarrays of strings. The subarrays will be merged into the higher array, allowing a parameterized array to appear as part of the string array.
For example, Integrator allows the Fileout columns attribute to appear as follows:
columns = { "Product",
"Company",
"Date",
`$(summaries)`,
`$(infos)`
},
Assume that the file "columns.txt" contains a list of columns that should be output from a given Integrator script. The file contains:
Product Salesperson Plan Units Actual Units
The columns attribute in a Fileout output object can be parameterized using the following:
object 'PARM' "parms" {
parms = {
{name = "column list",
type = "array",
default = "columns.txt",
}
}
};
object 'OUTP' "out" {
output_type = "fileout",
input = "input",
file_type = "column_headers",
filename = "out.txt",
columns = `$(column list)`, };
To override the default filename specified in the PARM object, the "column list" parameter can be given a filename on the command-line. For example:
-define "column list=new_columns.txt"
The column list is read from the file new_columns.txt instead of from the default columns.txt.