Declare a local variable
- Last UpdatedJul 23, 2024
- 1 minute read
You can declare local variables anywhere in your script, as long as you declare them before their first use. To declare a local variable, use the following statement:
DIM LocVarName [AS DataType];
LocVarName is the name of the local variable. The name must follow the naming conventions for tagnames. For more information, see Tag name conventions.
DataType is the data type of the local variable. Valid values are Discrete, Integer, Real, and Message. If you do not specify this option, Integer is used as the default.
You must use a separate DIM statement for each local variable to declare.
You can declare any number of local variables. The number is only limited by the available memory.
Examples
To declare an Integer variable:
DIM MyLocalIntVar AS Integer;
To declare multiple Real variables:
DIM MyLocalRealVar1 AS Real;
DIM MyLocalRealVar2 AS Real;
The following statement is not valid:
DIM MyLocalRealVar1, MyLocalRealVar2 AS Real;