| Aric Bills 2006-05-25, 4:15 am |
| When writing Tcl commands in C, you need to make a distinction between
the "status code" and the return value. Ironically, you provide the
status code with the [return] command, and you provide the return value
with Tcl_SetObjResult, Tcl_AppendResult, or some other such command.
I can see where you're going with your code; if you want to go that
route, you should do something like this:
if {[catch {check_hist_aint_option}]} {
# deal with the error
} else {
# proceed as normal
}
Another alternative is to return TCL_OK as the status code in either
case, and return true or false as the result. Something like:
if (can_do_histogram) {
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(1));
} else {
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(0));
}
return TCL_OK;
Your Tcl code can then go like this:
if {[check_hist_aint_option]} {
# proceed with histogram
} else {
# give negative feedback
}
Does that help?
|