Variables
Syntax
{
var1 = $expr1;
var2 = $expr2;
$result-expression-using-var1-and-var2;
}
Description
Values can be stored in a variable. This can be useful if one value is needed for several calculations. It is important to note that a "variable" in TL-Script can never change its value after it has been defined.
Variables can be passed as function arguments (see Functions) or explicitly defined themselves as shown above. The above example assigns to the variables var1
and var2
the result of the evaluations of the expressions expr1
and expr2
. The result of the total expression is the evaluation of result-expression-using-var1-and-var2
. This expression can access the variables $var1
and $var2
defined above.
A defined variable var = ...;
can be accessed with $var
. The variable is only visible in the block where it was defined.
Examples
{
x = 5;
y = 6;
$x * $y;
}
Output: 30
{
x = "Hello";
y = ", how are you?";
toString($x, $y);
}
Output: "Hello, how are you?"