NaviServer - programmable web server

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

# keyl(n) 4.99.8 naviserver "NaviServer Built-in Commands"

## Name

keyl - Keyed Lists

## Table Of Contents

## Synopsis

- keylget listvar ?key? ?retvar?
- keyldel listvar key
- keylset listvar key value ?key value...?
- keylkeys listvar ?key?

## Description

Keyed lists are an extension of Tcl provided by the TclX package. They are an alternative to using ns_set, but we highly recommend using ns_set instead of keyed lists where possible. The commands provided by NaviServer were taken directly from a 1995 version of the TclX package.

## COMMANDS

keylget listvar ?key? ?retvar?

  This command returns the value associated with key from the keyed list in the variable listvar. If retvar is not specified, then the value will be returned as the result of the command. In this case, if key is not found in the list, an error will result.

  If retvar is specified and key is in the list, then the value is returned in the variable retvar and the command returns 1. Otherwise, the command will return 0, and retvar will be left unchanged.

  If retvar is an empty string, the value is not returned, allowing the Tcl programmer to determine if a key is present in a keyed list without setting a variable as a side-effect. If key is omitted, then a list of all the keys in the keyed list is returned similar to

keyldel listvar key

  Delete key and value from keyed list

  This command deletes the key specified by key from the keyed list in listvar. This removes both the key and the value from the keyed list.

  Keyed lists are an extension of Tcl provided by the TclX package. They are an alternative to using ns_set, but we highly recommend using ns_set instead of keyed lists. The commands provided by NaviServer were taken directly from a 1995 version of the TclX package.

keylset listvar key value ?key value...?

  Set a key-value pair in a keyed list

  This command sets one or more key-value pairs in the keyed list listvar.

keylkeys listvar ?key?

  Return the keys for a keyed list.

  This command returns a list of keys for the keyed list listvar. If key is specified, the values for that key are returned instead.

## EXAMPLES

       % keylset mylist a b c d e f

       % keylkeys mylist
       a c e

       % keyldel mylist c

       % keylkeys mylist
       a e

       % keylset mylist a 1 {b c} 2

       % keylkeys mylist
       a {b c}

       % keylkeys mylist a
       1

## See Also

ns_set, nsd

## Keywords

TclX, keyldel, keylkeys, keylset