ad_return

EveAndersson.com : API Browser : ad_return

ad_return

ad_return [ args... ]
Defined in packages/acs-core/request-processor-procs.tcl

Works like the "return" Tcl command, with one difference. Where "return" will always return TCL_RETURN, regardless of the -code switch this way, by burying it inside a proc, the proc will return the code you specify.

Why? Because "return" only sets the "returnCode" attribute of the interpreter object, which the function actually interpreting the procedure then reads and uses as the return code of the procedure. This proc adds just that level of processing to the statement.

When is that useful or necessary? Here:

set errno [catch {
    return -code error "Boo!"
} error]
In this case, errno will always contain 2 (TCL_RETURN). If you use ad_return instead, it'll contain what you wanted, namely 1 (TCL_ERROR).

[ show source ]

Show another procedure:

eve@eveandersson.com