Global

Last Modified: 1/1/2021

Defines a variable that is accessible in every 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: Global <VariableName> As <Type> [* <Size> At <Location>]
    Global 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.

Global creates a variable that can be accessed in every scope. If you don't want the variable to be accessible everywhere, you can use the Dim command to limit the variable to the scope it is defined in.

See Also

Const, Dim