beetlebug▾
/

tcl::OptProc OptParse

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

tcl::OptParse DESCRIPTION ARGLIST

Description

Parses ARGLIST with DESCRIPTION once, with no key to keep, and sets a variable for each item in the frame of the caller.

Arguments

ArgumentTypeDefaultDescription
DESCRIPTIONlistrequiredThe list of the flags and the parameters.
ARGLISTlistrequiredThe words to parse.

Returns

An empty string.

Examples

Each example of this page runs after package require opt.

% tcl::OptParse {{x -int 0 "x"} {-v}} {7 -v}
> list $x $v
7 1

Errors

% tcl::OptParse {{x -int 0 "x"}} {a}
bad value "a" for parameter
    x int (0) x
-errorcode NONE

% tcl::OptParse {}
wrong # args: should be "tcl::OptParse desc 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