I am writing a proc to create a header in an output file.
Currently it needs to take an optional parameter, which is a possible comment for the header.
I have ended up coding this as a single optional parameter
proc dump_header { test description {comment = ""}}
but would like to know how I can achieve the same using args
proc dump_header { test description args }
It’s quite easy to check for args being a single blank parameter ($args == “”), but doesn’t cope well if passing multiple parameters – and I need the negative check anyway.
Your proc definition is incorrect (you’d get the error message
too many fields in argument specifier "comment = """). Should be:If you want to use
args, you could examine thellengthof it:You might also want to pass name-value pairs in a list:
Some prefer a combination of
argsand name-value pairs (a la Tk)