abort
Terminate statements out to an enclosing "catch $aborted()" statement.
track_planet command invokes
the abort command if asked to track the Sun. This
would abort not only the track_planet command, but
also the foreach loop that
called it. In fact, left unchecked it would abort all of the code
enclosing the foreach loop, and the scheduling script itself.
However this is prevented by the presence of
a catch statement that
includes a test of
the $aborted() function.
Because of this statement, only the section of code within the
catch statement is aborted, and the next statement to be run is
the first command after the catch statement.
command track_planet(Source $src) {
if($src == sun) {
print "The sun is not a planet!"
abort
}
...the tracking code...
}
catch $aborted {
foreach(Source s) {mars, sun} {
track_planet sun
}
}
print "Finished"
abort command is designed for signaling error
conditions in deeply nested loops or user defined commands, in a
way that can be caught for remedial action by enclosing catch
statements.
By default, when the abort command is invoked, it
terminates the schedule that contains it. However if
the abort statement is part of a section of code
that is enclosed by a catch
statement that calls
the $aborted() function,
then only that section of code is aborted.
Note that in cases where there are multiple
nested catch statements that
each invoke the $aborted()
function, then the innermost one is the only one that is
triggered, because the $aborted() function only
returns true once per abort.