i can make default values in my procs, f.e. proc1 {string1 string2 {nocase false}}... but how can i make options?
"[proc1 "asd" "qwe" -nocase]", is it possible?
Code: Select all
proc proc1 {string1 string2 args} {
#Instantiate option-variables
set nocase 0
#Do we have any options to care for?
if {[llength $args] > 0} {
#Iterate through the whole list of options...
foreach arg $args {
#... and parse each to see if they're valid or not.
#Use the "default" keyword to catch any unknown options and bail out.
switch -- $arg {
"-nocase" {
set nocase 1
}
default {
error "Unknown option \"$arg\""
}
}
}
}
#All options (if any) parsed, and option-variables properly updated,
# lets do the actual work now
...
}