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

NAME

8       global - Access global variables
9

SYNOPSIS

11       global ?varname ...?
12______________________________________________________________________________
13

DESCRIPTION

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

EXAMPLES

30       This procedure sets the namespace variable ::a::x
31
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
43              proc accum {string} {
44                  global accumulator
45                  append accumulator $string \n
46              }
47

SEE ALSO

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

KEYWORDS

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