Variable Names
Jump to navigation
Jump to search
The [[Scripting Language Syntax|scripting language] can define variables in command files and do calculations on variables with expressions.
Defining Variables
Variables are defined and used in the form #varname where varname is any valid variable name. A number sign must always be used to indicate a variable. The rules for a valid variable name after the number sign are:
- It must start with a letter or underscore
- It can be followed by any number of additional upper or lower case letters, underscores, or numbers.
- It may end in a dollar sign ($)
- Variable names are case sensitive.
Initializing a Variable
A variable is initially defined in an assignment statement such as:
#x=1
where the variable is set equal to the right side of the equals sign which can be any valid expression. A variable cannot be used in an expression until it has been defined.
Variable Arrays
Any valid variable name can be a variable array by following it with an expression in square brackets
#y[#j]=1
where
- The expression in the square brackets must evaluate to an integer index into the array.
- Multidimensional arrays are allowed such as #z[#i][#j]
- There is no need to define the dimension of arrays.