Skip to content

global ​

Access global variables from within a procedure.

Syntax ​

tcl
global ?varName ...?

Parameters ​

  • varName: One or more global variable names to link

Description ​

Creates local variables that refer to global namespace variables of the same name. Only meaningful inside procedures—at the global level, it has no effect. Changes to the local variable affect the global variable.

Examples ​

Accessing a global variable ​

Output

Multiple global variables ​

Output

Global vs local scope ​

Output

See Also ​

  • variable - Declare namespace variables
  • upvar - Reference variables in other frames
  • namespace - Create and manipulate namespaces