Dim

Define variables to be used in your program.

Syntax:
    Dim [Bank?] variableName [@ address] [.bit number] As Variable Type [= initial value]
   
Dim [Bank?] arrayName(size) As Variable Type
   
Dim [Bank?] stringName(size) As String [= initial value]

Bank? is an optional keyword defining the bank all variables defined in the current Dim statement will be placed. The "?" should be replaced with the bank number or letter.

Multiple variables can be defined by separating each one with a comma (,). @address and .bit number are optional.

Optional initial values can be added after the variable type for Strings and non array variables. If the variable is global, the initial value will be assigned at the beginning of Sub main.  Otherwise, the value is assigned at the location of the Dim statement.


 

Example:

Dim RB0 @ PORTB.0 As Boolean
Dim Bank2 a As Byte, b As Integer   ' a and b are placed in bank 2
Dim buffer(100) As uByte
Dim str(20) As String
Dim a as byte = 0, b as byte = 12   ' a is initialized to 0 and
                                    ' b is initialized to 12

Also See: Variable Types