tsv get
Gives the value of an element of a shared array.
tsv::get ARRAY ELEMENT ?VARNAME?
Description
The command tsv::get gives the value of the element ELEMENT of ARRAY. With VARNAME, it gives 1 and puts the value in the variable when the element exists, and gives 0 and leaves the variable as it is when it does not, so the form is a test and a read in one step.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| ARRAY | array name | required | The name of the shared array. |
| ELEMENT | string | required | The name of the element. |
| VARNAME | variable name | none | The variable for the value. |
Returns
The value, or 1 or 0 with VARNAME.
Examples
% tsv::set a x 1
> tsv::get a x
1
% tsv::set a x 1
> list [tsv::get a x v] $v
1 1
% tsv::set a x 1
> tsv::get a nope v
0
Errors
% tsv::get
wrong # args: should be "tsv::get array key ?args?"
-errorcode TCL WRONGARGS
% tsv::set a x 1
> tsv::get a nope
no key a(nope)
-errorcode NONE
% tsv::get nope x
"nope" is not a thread shared array
-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