userVariable Statement

Added: build 155

Purpose

Creates user-defined variables that may be used within other statements.

Applicability

This statement can be used within run, fileToGenerate, fileToParse, templateFile, or initializationFile statements.

Additional Information

Syntax

userVariable: <name> <type> [default=value][description=string]
[units=value][upperBound=value]
[lowerBound=value]
[enumValues=val1,val2,...,valN]
[enumAliases=val1,val2,...,valN]

Arguments

Name Description
name The name is a string that specifies what the variable will be called.
type The type can be any primitive type supported by the Analysis Server: double, integer, string, and boolean.

Options

Name Description
default This option can be used to specify a default value.
description This option allows the user to write a description for the variable.
units This option allows the user to write a units string for the variable.
upperBound This option allows the user to set an upper bound for the variable.
lowerBound This option allows the user to set a lower bound for the variable.
enumValues This option allows the user to specify the set of possible values for the variable. The enumerated values are specified as a comma separated list of values.
enumAliases New as of build 169. This option allows the user to specify a set of string values that may be associated with the enumerated values. If the variable is set to a value in the alias set, the actual value will be set to the corresponding value in the enumValues set. The aliases are specified as a comma separated list of values. There must be the same amount of elements in the enumValues and enumAliases sets.

Example

The user wants to be able to specify the name of an output file at run time. The program being wrapped specifies the input and output files as the first and second command line arguments
userVariable: outFileName string default=out.dat

RunCommands
{
generate inFile
run "myProg in.dat $outFileName"
parse outFile
}

RowFieldOutputFile outFile
{
fileToParse: $outFileName
...
}
In this example, a user variable named "outFileName" was created. This variable was then used in both the run statement and the fileToParse statement.

Note: As of build 191, curly braces can also be used to indicate where to substitute values. For example, to specify the same name for the input and output files in the above example, the following commands could be used:

userVariable: fileName string default=values

RunCommands
{
generate inFile
run "myProg ${fileName}.in ${fileName}.out"
parse outFile
}

RowFieldInputFile outFile
{
fileToGenerate: ${fileName}.in
...
}

RowFieldOutputFile outFile
{
fileToParse: ${fileName}.out
...
}

See also Analysis Server | FileWrapper | FileWrapper Statements