Declarative variable

In AskiaScript, a declarative variable is a temporary, custom variable created to store and manipulate data temporarily, within a script.

The declarative variable is in the local scope, which means it is available only during the execution of the current condition/action or in the context (label) of the inline script.

Declaration

Use the dim keyword to declare a variable in AskiaScript, followed by the name of the variable. The name of the variable:

Note: unlike with question variables, there is no work-around for the above rules (^my variable^ is not allowed).
Example

dim my_variable

Assignment

You can assign a value to a declarative variable using the equals sign (=) (see also topics assignment vs comparison). It is possible to assign a value after or during the declaration of the variable:

dim my_variable

my_variable = 1

OR

dim my_variable = 1

Unless the type of the variable is specified, the first assignment of the variable determines its final type; the type of the variable cannot be changed during the AskiaScript execution. For example:

dim my_variable = 12   ' => The variable is a number
my_variable = "abc"     ' => Try to assign a string in a number variable: raises an exception

Exceptions

Exceptions occur if you attempt to:

Create your own Knowledge Base