var

Overview

The var statement is used to create or update a variable.

Several variables are automatically created before the commencement of a Transcript task. Please refer to the Variables section in the Introduction to this guide for further details.

Syntax

varname=value

As the value may be derived from an expression (see Using an expression to set a variable below) it is recommended that variable values be quoted in order to avoid characters such as / being interpreted as mathematical operators.

Details

A variable is a named value. Once defined, the name can be used in place of the value for the rest of the transcript task. This can be useful in that it permits the configuration of various parameters at the top of a transcript task, which makes maintenance easier.

Both the name and the value parameters must be present, and there must be a space on each side of the = character. To use a space or tab in a variable value, use an escape or double quote the value:

var example = "Hello world"
var example = Hello\ world

A variable is referenced by enclosing its name with ${ and }. For example, a variable called outputFile can be referenced using ${outputFile}.

Variable names are case sensitive, therefore ${variableName} and ${VariableName} are separate variables.

If there is already a variable called name then the var statement will update the value.

The value of a variable may not exceed 1023 characters

Using an expression to set a variable

As well as a literal value, an expression may be specified, in which case the variable is set to the output of that expression. For example:

var value1 = 5
var value2 = 10
var largest = @MAX(${value1}, ${value2})

For a full list of available functions please refer to the functions section of the documentation for the if statement.

Example

# ----> Start Config <----
var tmp_folder = AzureTmp
# ----> End Config <----

import "system/extracted/${tmp_folder}/${dataDate}.csv" source Azure alias usage
import "system/extracted/${tmp_folder}/rates.csv" source source Azure alias rates

Last updated