1global(n)                    Tcl Built-In Commands                   global(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       global - Access global variables
9

SYNOPSIS

11       global varname ?varname ...?
12_________________________________________________________________
13
14

DESCRIPTION

16       This  command  has  no  effect unless executed in the context of a proc
17       body.  If the global command is executed in the context of a proc body,
18       it creates local variables linked to the corresponding global variables
19       (though these linked variables, like those created by  upvar,  are  not
20       included in the list returned by info locals).
21
22       If  varname contains namespace qualifiers, the local variable's name is
23       the unqualified name of the  global  variable,  as  determined  by  the
24       namespace tail command.
25
26       varname  is always treated as the name of a variable, not an array ele‐
27       ment.  An error is returned if the name looks like  an  array  element,
28       such as a(b).
29

EXAMPLES

31       This procedure sets the namespace variable ::a::x
32              proc reset {} {
33                  global a::x
34                  set x 0
35              }
36
37       This procedure accumulates the strings passed to it in a global buffer,
38       separated by newlines.  It is useful for situations when  you  want  to
39       build  a  message  piece-by-piece  (as if with puts) but send that full
40       message in a single piece (e.g. over a connection opened with socket or
41       as part of a counted HTTP response).
42              proc accum {string} {
43                  global accumulator
44                  append accumulator $string \n
45              }
46
47

SEE ALSO

49       namespace(n), upvar(n), variable(n)
50
51

KEYWORDS

53       global, namespace, procedure, variable
54
55
56
57Tcl                                                                  global(n)
Impressum