#DIM ALL / #DIM NONE

Syntax:
#DIM ALL
#DIM NONE

Description

The #DIM ALL and #DIM NONE directives control whether variables must be explicitly declared before use. This is a compile-time directive that affects the entire source file from the point it appears.

Using #DIM ALL is strongly recommended for catching typos and enforcing disciplined variable management.

Parameters

ParameterDescription
(none)This directive takes no parameters. It is placed on its own line to set the variable declaration mode.

Example

#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL x AS LONG
    LOCAL name AS STRING

    x = 42
    name = "PBXA64"
    PRINT name; " value: "; x

    ' This would cause an error with #DIM ALL:
    ' y = 99   ' ERROR: Undeclared variable

    FUNCTION = 0
END FUNCTION

Notes