Variables

You can use variables to store the result of an expression under a symbolic name. The value of a variable can be modified at any point in a script by assigning a new expression to the variable.

The following keywords cannot be used as variable name: NOT, FI, ELSE, ELIF, OD, TRUE, FALSE.

The following rules apply to all variables:

  • A variable name consists of any sequence of alphanumeric characters and the underscore (A-Z, a-z, 0-9 and _). A variable name cannot begin with a digit or an underscore.
  • The symbolic names of variables, parameters, and constants must all be unique within their script. The symbolic names of variables are case-sensitive.
  • You can only use a variable declared in a conditional or iterating statement from its definition until the end of that statement (statement scope).
  • You can declare variables everywhere in the script. They must be declared before you can actually use them. If there is an initial value assigned to the variable, it is evaluated at the moment the variable is declared. If there is no value assigned, the variable is initialized using an empty value.

Syntax

Var type name = expression;
Var type name;

For the first Var type you have to assign an initial value, while the second has no initial value. A variable is empty until a value is assigned to it.

Variable types

The declaration assigns a type to the variable and only values with that type can be assigned to the variable. There are three types of variables:

  • Text
  • Boolean
  • Number

Values of type Number in KCM Core must lie between -2.147.483.648 and +2.147.483.647.