diff options
Diffstat (limited to 'doc/array.n')
| -rw-r--r-- | doc/array.n | 78 |
1 files changed, 9 insertions, 69 deletions
diff --git a/doc/array.n b/doc/array.n index 268597d..056992c 100644 --- a/doc/array.n +++ b/doc/array.n @@ -4,8 +4,8 @@ '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. -'\" -.TH array n 8.7 Tcl "Tcl Built-In Commands" +'\" +.TH array n 8.3 Tcl "Tcl Built-In Commands" .so man.macros .BS '\" Note: do not modify the .SH NAME line immediately below! @@ -36,53 +36,6 @@ with an empty name, since the return value from \fBarray nextelement\fR will not indicate whether the search has been completed. .TP -\fBarray default \fIsubcommand arrayName args...\fR -.VS TIP508 -Manages the default value of the array. Arrays initially have no default -value, but this command allows you to set one; the default value will be -returned when reading from an element of the array \fIarrayName\fR if the read -would otherwise result in an error. Note that this may cause the \fBappend\fR, -\fBdict\fR, \fBincr\fR and \fBlappend\fR commands to change their behavior in -relation to non-existing array elements. -.RS -.PP -The \fIsubcommand\fR argument controls what exact operation will be performed -on the default value of \fIarrayName\fR. Supported \fIsubcommand\fRs are: -.VE TIP508 -.TP -\fBarray default exists \fIarrayName\fR -.VS TIP508 -This returns a boolean value indicating whether a default value has been set -for the array \fIarrayName\fR. Returns a false value if \fIarrayName\fR does -not exist. Raises an error if \fIarrayName\fR is an existing variable that is -not an array. -.VE TIP508 -.TP -\fBarray default get \fIarrayName\fR -.VS TIP508 -This returns the current default value for the array \fIarrayName\fR. Raises -an error if \fIarrayName\fR is an existing variable that is not an array, or -if \fIarrayName\fR is an array without a default value. -.VE TIP508 -.TP -\fBarray default set \fIarrayName value\fR -.VS TIP508 -This sets the default value for the array \fIarrayName\fR to \fIvalue\fR. -Returns the empty string. Raises an error if \fIarrayName\fR is an existing -variable that is not an array, or if \fIarrayName\fR is an illegal name for an -array. If \fIarrayName\fR does not currently exist, it is created as an empty -array as well as having its default value set. -.VE TIP508 -.TP -\fBarray default unset \fIarrayName\fR -.VS TIP508 -This removes the default value for the array \fIarrayName\fR and returns the -empty string. Does nothing if \fIarrayName\fR does not have a default -value. Raises an error if \fIarrayName\fR is an existing variable that is not -an array. -.VE TIP508 -.RE -.TP \fBarray donesearch \fIarrayName searchId\fR This command terminates an array search and destroys all the state associated with that search. \fISearchId\fR indicates @@ -94,15 +47,6 @@ been the return value from a previous invocation of Returns 1 if \fIarrayName\fR is an array variable, 0 if there is no variable by that name or if it is a scalar variable. .TP -\fBarray for {\fIkeyVariable valueVariable\fB} \fIarrayName body\fP -The first argument is a two element list of variable names for the -key and value of each entry in the array. The second argument is the -array name to iterate over. The third argument is the body to execute -for each key and value returned. -The ordering of the returned keys is undefined. -If an array element is deleted or a new array element is inserted during -the \fIarray for\fP process, the command will terminate with an error. -.TP \fBarray get \fIarrayName\fR ?\fIpattern\fR? Returns a list containing pairs of elements. The first element in each pair is the name of an element in \fIarrayName\fR @@ -192,14 +136,14 @@ The command always returns an empty string. .SH EXAMPLES .CS \fBarray set\fR colorcount { - red 1 - green 5 - blue 4 - white 9 + red 1 + green 5 + blue 4 + white 9 } foreach {color count} [\fBarray get\fR colorcount] { - puts "Color: $color Count: $count" + puts "Color: $color Count: $count" } \fB\(->\fR Color: blue Count: 4 Color: white Count: 9 @@ -207,7 +151,7 @@ foreach {color count} [\fBarray get\fR colorcount] { Color: red Count: 1 foreach color [\fBarray names\fR colorcount] { - puts "Color: $color Count: $colorcount($color)" + puts "Color: $color Count: $colorcount($color)" } \fB\(->\fR Color: blue Count: 4 Color: white Count: 9 @@ -215,7 +159,7 @@ foreach color [\fBarray names\fR colorcount] { Color: red Count: 1 foreach color [lsort [\fBarray names\fR colorcount]] { - puts "Color: $color Count: $colorcount($color)" + puts "Color: $color Count: $colorcount($color)" } \fB\(->\fR Color: blue Count: 4 Color: green Count: 5 @@ -241,7 +185,3 @@ foreach color [lsort [\fBarray names\fR colorcount]] { list(n), string(n), variable(n), trace(n), foreach(n) .SH KEYWORDS array, element names, search -.\" Local variables: -.\" mode: nroff -.\" fill-column: 78 -.\" End: |
