Local Variable Declaration
DIM Identifier AS Datatype [ = Expression ]
Declare a local
variable in a procedure or function.
This variable is only accessible to the procedure or function where it is declared.
Example
DIM iVal AS Integer
DIM sName AS String
DIM hObject AS Object
DIM hCollection AS Collection
Initialization
The
variable can be initialized with any expression.
Example
DIM bCancel AS Boolean = TRUE
DIM Languages AS String[] = [ "fr", "it", "es", "de", "ja" ]
DIM DefaultLanguage AS String = Languages[1]
Alternatively, you can initialize the variable with a newly instanciated
objekt.
DIM Identifier AS NEW Class ( Arguments ... )
DIM aTask AS NEW String[]
DIM aCollection AS NEW Collection(gb.Text)
Or you can initialize the variable with a native
Dynamické pole.
See
Deklarace pole for more information.
Multiple Declarations
You can declare several variables on the same line:
- Each declaration must be separated by a comma.
- You can specify the identifier only. It will have the same declaration as the first next identifier having a complete declaration.
Example
DIM Text AS String, Matrix AS NEW Float[3, 3]
DIM X, Y, W, H AS Integer