MAXScript Language Reference > Variables - Assignment and Scope >

# Definition Constructs Can Include Global Variable Declarations At Top Level

All the major definition constructs in MAXScript (such as utility, rollout, macroScript, rcmenu, tool, plug-in, etc.) can now include global variable declarations at the top-level within them.

EXAMPLE
    rollout foo "foo"
    (
    local a, b = undefined, c
    global d, e = 3 -- now possible
    spinner bar "Bar"
    checkBox baz "Baz: "
    on bar changed do...
    )

In releases prior to 3ds Max 4, globals had to be declared inside on-handler bodies. Any initializers present in a global declaration like this are at compile time, so the initial value expressions must be executable at the time the script is compiled.

#### See Also

- Variable Assignment

- Scope of Variables

- Specifying Global Variables As Global Using ::

- Persistent Global Variables

- Type-Free Variables

- Reference Assignment