MC-Basic:ONERROR

From SoftMC-Wiki
Revision as of 08:39, 22 May 2014 by Miborich (talk | contribs) (Miborich moved page Axystems:MC-Basic:ONERROR to MC-Basic:ONERROR: Global renaming of Axystems: namespace into (Main):)
Jump to: navigation, search

The ONERROR statement is used to trap and process both synchronous and asynchronous errors in a task. A synchronous error is one caused by the user task, and is detected by the interpreter, while an asynchronous error is not associated with a specific line of program code. Examples include position following errors. Errors not trapped by a TRY/FINALLY mechanism within the task are trapped by ONERROR. When an error is trapped, the specified error processing code is run and the task is stopped. The task is in state 4. Task execution is resumed by explicitly entering the CONTINUETASK command within the error processing code.

NOTE-Info.svgNOTE

SYNCHRONOUS errors stop a task that catches them by means of "onerror" so that a "continuetask" is needed

ASYNCHRONOUS errors do not stop a task even if caught from "onerror" so the task is automatically  continuing.

Syntax

Program                        'Beginning of program
  <Code>
  OnError                      'Start of OnError block
    {catch <error number X>
      <code to execute when error X occurs>}
    {catch <error number Y>
      <code to execute when error Y occurs>}
    {catch else
      <code to execute for all other errors>}
  End OnError                  'End of OnError block
  <Code>
End Program                    'End of program

Availability

All versions

Type

NA

Range

NA

Units

NA

Default

NA

Scope

Task

Limitations

ONERROR traps only errors associated with the task in which they are defined.

Nesting of ONERROR is not allowed.

Examples

OnError

catch 3017

print "Position Following Error"

System.motion = 0                    'Stop all motion

killtask task2.prg

End OnError

See Also