beetlebug▾
/

tsv keylget

Gives the value of a key of a keyed list in a shared array.

tsv::keylget ARRAY ELEMENT ?KEY? ?VARNAME?

Description

The command tsv::keylget gives the value of KEY in the keyed list of the element. A KEY with dots is a path. With VARNAME, it gives 1 and puts the value in the variable when the key exists, and gives 0 when it does not. With no KEY, it gives the keys of the top level, as tsv::keylkeys does.

Arguments

ArgumentTypeDefaultDescription
ARRAYarray namerequiredThe name of the shared array.
ELEMENTstringrequiredThe name of the element.
KEYkey, or a path of keys with dotsnoneThe key to read.
VARNAMEvariable namenoneThe variable for the value.

Returns

The value, 1 or 0 with VARNAME, or a list of keys with no KEY.

Examples

% tsv::keylset k e name Ann a.b 1
> tsv::keylget k e name
Ann

% tsv::keylset k e name Ann a.b 1
> tsv::keylget k e a.b
1

% tsv::keylset k e name Ann
> list [tsv::keylget k e name v] $v [tsv::keylget k e nope w]
1 Ann 0

% tsv::keylset k e3 name Ann age 30
> tsv::keylget k e3
name age

Errors

% tsv::keylset k e name Ann
> tsv::keylget k e nope
key "nope" not found
-errorcode NONE

% tsv::keylget nope e name
"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

See also