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

NAME

8       array - Manipulate array variables
9

SYNOPSIS

11       array option arrayName ?arg arg ...?
12______________________________________________________________________________
13

DESCRIPTION

15       This  command  performs one of several operations on the variable given
16       by arrayName.   Unless  otherwise  specified  for  individual  commands
17       below,  arrayName  must be the name of an existing array variable.  The
18       option argument determines what action is carried out by  the  command.
19       The legal options (which may be abbreviated) are:
20
21       array anymore arrayName searchId
22              Returns 1 if there are any more elements left to be processed in
23              an array search, 0 if all elements have already  been  returned.
24              SearchId  indicates which search on arrayName to check, and must
25              have been the return value from a previous invocation  of  array
26              startsearch.  This option is particularly useful if an array has
27              an element with an empty name, since the return value from array
28              nextelement  will  not indicate whether the search has been com‐
29              pleted.
30
31       array donesearch arrayName searchId
32              This command terminates an array search  and  destroys  all  the
33              state  associated  with  that  search.  SearchId indicates which
34              search on arrayName to destroy, and must have  been  the  return
35              value  from a previous invocation of array startsearch.  Returns
36              an empty string.
37
38       array exists arrayName
39              Returns 1 if arrayName is an array variable, 0 if  there  is  no
40              variable by that name or if it is a scalar variable.
41
42       array get arrayName ?pattern?
43              Returns  a list containing pairs of elements.  The first element
44              in each pair is the name of an element in arrayName and the sec‐
45              ond element of each pair is the value of the array element.  The
46              order of the pairs is undefined.  If pattern is  not  specified,
47              then  all  of  the  elements  of  the  array are included in the
48              result.  If pattern is specified, then only those elements whose
49              names  match  pattern (using the matching rules of string match)
50              are included.  If arrayName is not the name of  an  array  vari‐
51              able,  or  if the array contains no elements, then an empty list
52              is returned.  If traces on the array modify  the  list  of  ele‐
53              ments,  the  elements  returned are those that exist both before
54              and after the call to array get.
55
56       array names arrayName ?mode? ?pattern?
57              Returns a list containing the names of all of  the  elements  in
58              the array that match pattern.  Mode may be one of -exact, -glob,
59              or -regexp.  If specified, mode designates which matching  rules
60              to use to match pattern against the names of the elements in the
61              array.  If not specified, mode defaults to -glob.  See the docu‐
62              mentation  for string match for information on glob style match‐
63              ing, and the documentation for regexp for information on  regexp
64              matching.  If pattern is omitted then the command returns all of
65              the element names in the array.  If there are no (matching) ele‐
66              ments  in the array, or if arrayName is not the name of an array
67              variable, then an empty string is returned.
68
69       array nextelement arrayName searchId
70              Returns the name of the next element in arrayName, or  an  empty
71              string  if  all elements of arrayName have already been returned
72              in this s