nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Jul 28, 2008 9:36 am Post subject: |
|
|
I believe you are looking for the special parameter called "args", which accepts 0 or more values..
| Code: | 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
...
} |
Of course, this could also be done in some manner using default values, although ordering would become an issue. The above example still requires the first two parameters to be the strings to be operated on, however, should you support numerous options, the order among those would not matter. With some modification, you could also support options with values, such as "[proc2 word1 word2 -format "%s - %s"]" _________________ NML_375, idling at #eggdrop@IrcNET |
|