beetlebug▾
/

tcl::OptProc OptKeyParse

Parses a list of words with a kept description, and sets a variable for each item.

tcl::OptKeyParse KEY ARGLIST

Description

Parses ARGLIST with the description of KEY, and sets a variable for each item in the frame of the caller, as the body of a proc of tcl::OptProc sees them. A word that does not fit is an error with the table of the items.

Arguments

ArgumentTypeDefaultDescription
KEYstringrequiredA key of tcl::OptKeyRegister.
ARGLISTlistrequiredThe words to parse.

Returns

An empty string.

Examples

Each example of this page runs after package require opt.

% tcl::OptKeyRegister {{x -int 0 "x"} {-y}} k1
> proc g {args} {tcl::OptKeyParse k1 $args; list $x $y}
> list [g 5 -y] [g 5]
{5 1} {5 0}

Errors

% tcl::OptKeyParse nokey {}
can't read "OptDesc(nokey)": no such element in array
-errorcode TCL READ VARNAME

% tcl::OptKeyParse k
wrong # args: should be "tcl::OptKeyParse key arglist"
-errorcode TCL WRONGARGS

Facts

Capability
package. 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