#DIM ALL#DIM NONE
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.
LOCAL, STATIC, GLOBAL, or DIM before they can be used. Using an undeclared variable produces a compile-time error.
Using #DIM ALL is strongly recommended for catching typos and enforcing disciplined variable management.
| Parameter | Description |
|---|---|
| (none) | This directive takes no parameters. It is placed on its own line to set the variable declaration mode. |
#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
#DIM ALL can be placed multiple times in a file but its effect is global; the last occurrence before any code determines the mode.#DIM ALL is the recommended default for production code.#DIM NONE is active (or no directive is given), variables spring into existence on first assignment and default to the variant type. This can lead to subtle bugs.LONG, DWORD, STRING, etc.).