[ic] Usertag return value

Davor Ocelic docelic at spinlocksolutions.com
Thu Feb 5 23:11:16 UTC 2009

On Thu, 5 Feb 2009 11:05:12 -0800
Daniel Browning <db at endpoint.com> wrote:

> On Thursday 05 February 2009 10:47:10 am Grant wrote:
> > but that kills the whole page.  What is the correct way to do this
> > so I can evaluate whether or not the tag executed properly?
> You could use exceptions with an Interchange [try] block (see 
> etc/log_transaction for an example), but I think a simple return
> value would suffice in this case. If you want a "0" return value when
> one or more of the sizes fails, then use a return value variable and
> only set it to true if all three succeed.


Right, there's a bunch of ways to do this, depending on
whether you want to know which one failed (and exit immediately),
or you want to run all three anyway and just indicate the exit
status more as an information than an error.

If you want to exit immediately when one fails, use i.e.:

do_resize(....) or return 0;

(The above assumes do_resize() indicates success with non-zero value.
If it instead indicates failure with non-zero value, replace "or" with

Another approach, if you want to run all three always, and just use
exit status as an information to see which one(s) failed:

$ret= 0;
do_resize1(...) or $ret+= 1;
do_resize2(...) or $ret+= 2;
do_resize3(...) or $ret+= 4;
return $ret;

So if the tag exits with 0, it worked. Otherwise, the exit
status will be a sum of all resizes that failed. I.e. if 
exit value is 5, it means resizes 1 and 3 failed.


More information about the interchange-users mailing list