tsv lindex
Gives one element of a list in a shared array.
tsv::lindex ARRAY ELEMENT INDEX
Description
The command tsv::lindex gives the element at INDEX of the list in the element, as lindex does with one index. An index before the start or after the end gives an empty string.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| ARRAY | array name | required | The name of the shared array. |
| ELEMENT | string | required | The name of the element. |
| INDEX | index | required | An integer, end, or end-N. |
Returns
The element, or an empty string.
Examples
% tsv::set l x {a b c}
> tsv::lindex l x 1
b
% tsv::set l x {a b c}
> tsv::lindex l x end
c
% tsv::set l x {a b c}
> tsv::lindex l x 9
Errors
% tsv::set l x {a b c}
> tsv::lindex l x bad
bad index "bad": must be integer?[+-]integer? or end?[+-]integer?
-errorcode TCL VALUE INDEX
% tsv::set l x {a b c}
> tsv::lindex l x
wrong # args: should be "tsv::lindex l x index"
-errorcode TCL WRONGARGS
% tsv::set l x {a b c}
> tsv::lindex l nope 0
no key l(nope)
-errorcode NONE
Facts
- Capability
thread. A new interpreter does not have it until the host turns it on.- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1