template::util::get_opts (public)

 template::util::get_opts argv

Defined in packages/acs-templating/tcl/util-procs.tcl

Builds an array named "opts" in the calling frame, containing all switches passed at the end of a proc. The array values are either switch parameters or 1 if no parameter was specified. Problem: there is currently no way to specify an option parameter that begins with a dash. This particularly problematic for negative numbers.

Parameters:
argv (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_get_opts get_opts (test acs-templating) template::util::get_opts template::util::get_opts test_get_opts->template::util::get_opts doc::get_proc_doc doc::get_proc_doc (private, deprecated) doc::get_proc_doc->template::util::get_opts publish::handle::image publish::handle::image (public) publish::handle::image->template::util::get_opts publish::handle::text publish::handle::text (public) publish::handle::text->template::util::get_opts publish::handle_binary_file publish::handle_binary_file (public) publish::handle_binary_file->template::util::get_opts publish::handle_item publish::handle_item (private) publish::handle_item->template::util::get_opts

Testcases:
get_opts
Source code:

    upvar opts opts

    set size [llength $argv]

    # append a switch break
    lappend argv "-*"

    for { set i 0 } { $i < $size } {} {

        # Get a switch
        set opt [string trimleft [lindex $argv $i] -]

        # Get the next arg
        set next [lindex $argv [incr i]]

        if { [string index $next 0] ne "-"
             || ![regexp {[a-zA-Z*]} [string index $next 1] match] } {

            # the next arg was not a switch so assume it is a parameter
            set opts($opt$next
            # advance the counter past the switch parameter
            incr i

        } else {

            # the next arg was a switch so just use 1 as the parameter
            set opts($opt) 1
        }
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: