Dim

Last Modified: 1/1/2021

Defines a variable for the current scope.

Arguments

NameTypeRequiredDescription
VariableName N/A Yes The name of the variable.
Type System Identifier Yes The data type of your variable.
Size Number No The size of the variable. This is only valid for strings.
Location Line Label/Address No The line label or memory address to assign the variable.

Data types

Data TypeSuffixLengthRange
Byte N/A 1 Byte 0 to 255
Integer N/A 2 Bytes 0 to 65535
Signed Integer N/A 2 Bytes -32767 to 32767
Long & 4 Bytes 0 to 4294967295
Char $ 1 Byte 1 Character
String $ 128 Bytes 1 to 128 Characters

Example

Syntax: Dim <VariableName> As <Type> [* <Size> At <Location>]
    Dim a As Integer, b&(1) As Long At MyData
    Print b&(1)
MyData:
    DataLong 53214,100962

Remarks

Long, String, and Char variables require their suffix when declaring them. Only String variables can be resized using * <Size>.

Variables defined with At will be read only.

Dim creates a variable for the scope it's being defined in. Scopes are sub routines, functions, and main. If you define a varibale in one user defined routine, it won't be accessible in another routine, or in the main scope. If you want a variable to be accessible anywhere in the project, use the Global command.

See Also

Const, Global