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):
- 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