Dim

Syntax:

    For Variables:
    Dim variable    // will define a Byte variable
    Dim variable [As type]
    Dim variable [As type] [= initialvalue]
    Dim variable[, variable2 [, variable3]] [As type] [Alias othervar [, othervar2]]  [= initialvalue]
    Dim variable[, variable2 [, variable3]] [As type] [At location] [= initialvalue]

    For Arrays:
    Dim array(size) [As type] [At location]

    For Strings:
    Dim string [* size] [At location]

Explanation:

The Dim command is used to declare variables, arrays, and strings. It can also create aliases for existing variables or place variables at specific memory locations.

GCBASIC supports optional initialisation at the point of declaration:

    Dim byte_var As Byte = 1

This sets the variable to the specified value at program start. The traditional form remains fully valid:

    Dim byte_var As Byte

If no initial value is provided, the variable is initialised to zero unless the compiler determines otherwise.

Command Availability: Available on all microcontrollers.