Tcl error : wrong # args: should be "set varName ?newValue?" Tcl error : wrong # args: should be "set varName ?newValue?" unix unix

Tcl error : wrong # args: should be "set varName ?newValue?"


That message:

wrong # args: should be "set varName ?newValue?"

is a standard error thrown when a built-in command gets the wrong number of arguments to evaluate. In this case, it's coming from the set command, and indicates that you've either said set on its own, or given more than two further arguments to it.

If you examine the stack trace (usually printed with the error message when using standard tclsh, though it's changeable with user code) then you'll get told where the problem happened. However, in this case we can look through and see that this line near the bottom of the script:

            set ag_around_water resid [$ag_around_water get resid]

has what appears to be a space instead of an underscore in the variable name. Now, spaces are legal in variable names, but then the variable name needs to be quoted, and that can get a bit annoying. It's usually best to avoid using them like that. Without quoting, Tcl doesn't know that that's meant to be one word; the generic parsing layer decides there's really four words there (set, ag_around_water, resid and the complex [$ag_around_water get resid]) and tells set to deal with that, which it doesn't like.

Remember, Tcl's generic syntactic parsing happens first, before command arguments are interpreted semantically. Always.


The line set ag_around_water resid [$ag_around_water get resid] needs to be changed. You probably want ag_around_water_resid instead.