Index

return

Finish executing the enclosing user-defined command without executing any more of its statements.

Arguments:
(none)

Example:
In the following user-defined command, which doesn't use the return command, a mess of nested if statements are needed to ensure that after receiving a quit signal, no more of the statements in the command are run.
command do_the_observations() {
  if(!$signaled(quit)) {
    track Jupiter
    until $aquired(source) | $signaled(quit)
    if(!$signaled(quit)) {
      noise_cal on
      until $elapsed > 10s | $signaled(quit)
      if(!$signaled(quit)) {
        offset dk=-90
      }
    }
  }
}
This can be avoided by using the return command, to terminate the command early. This would be done by rewriting the above command as follows.
command do_the_observations() {
  if($signaled(quit)) {
    return
  }
  track Jupiter
  until $aquired(source) | $signaled(quit)
  if($signaled(quit)) {
    return
  }
  noise_cal on
  until $elapsed > 10s | $signaled(quit)
  if($signaled(quit)) {
    return
  }
  offset dk=-90
}


Context:
The return command is generally used to avoid having to have too many nested if statements within a command. It immediately terminates the execution of the enclosing user-defined command. If it is called outside of a command definition, it terminates the whole script.

Martin Shepherd (18-Nov-1999)