var [type] name [= exp], ...The var command defines variables for later use. The var command consists of an optional type declaration (string, int, float, bool, date, time, timestamp) followed by a comma separated list of variable declarations. Each variable declaration consists of a variable name followed by an optional initialization.
A Jive variable name begins with a letter or underscore followed by zero or more letters, underscores and numeric digits. Variable names can also be quoted using the back quote (`). Back quoted variables can contain Jive keywords, delimiters and spaces.
Variable initialization is optional. It consists of an equal sign (=) followed by an initialization expression. For example,
var int x = 0If the type declaration is omitted, the type of each variable declared is determined by the initialization expression. If both the type and initialization is omitted, the variable is declared as type bool with value null.
Variables can be redefined within a block. A second declaration of a variable in a block will completely replace the first. The type may be changed in the second declaration.
If the initialization expression is a list, the elements of the list form the initialization array. The list is enclosed in braces with comma separators. Each list element is an initialization expression. For example,
var string choices[] = {'Vanilla','Chocolate','Strawberry'}
Once the initialization array is determined, it is assigned to the array
variable. If the number of elements is not defined, the number of
elements in the initialization array is used. The elements of the new
variable array are then set one by one from the initialization array.
The initialization array is truncated or extended with null elements
as needed.
Type conversion is perform if a type was declared. Otherwise, the type of the initialization array element is used to type each element. This allows arrays with elements of mixed type:
var mixed[] = {'text',123,4.567,1996/1/1,true}
set array[2] = array[1]References outside of array bounds are null. Non-array variables may also be subscripted. They are treated like single element arrays. If an array variable is referenced without subscript, the first element is retrieved, as if '[0]' was appended to the name.
The @ is also unary but takes a full initialization expression as an operand. If the expression is an array, each of its elements is converted to string and concatenated together to form a single string. If the expression is not an array, it is simply converted to string.