MC-Basic:ONSYSTEMERROR

From SoftMC-Wiki
Jump to: navigation, search
Language: English  • 中文(简体)‎

The ONSYSTEMERROR statement is used to trap and process errors in the system. It is the upper level of the hierarchical error processing structure formed by the combination of TRY, ONERROR and ONSYSTEMERROR.

ONSYSTEMERROR is written in the body of a task, but only one instance may exist in the system at any time. It is used to trap both synchronous and asynchronous errors in all tasks, as well as errors that occur within the context of the system.

Synchronous errors are caused by the user task and detected by the interpreter, while an asynchronous errors are not associated with a specific line of program code. Examples include position following errors.

A system error is not associated with a specific task. An example of a system error is a position following error that occurs due to some external force being applied to an axis not attached to a task.

When an error is trapped, the specified error processing code is executed 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.

ONSYSTEMERROR is used to trap errors not specifically trapped by TRY or ONERROR. It is then either used to execute an orderly shutdown of the system, or an orderly recovery procedure.

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 "onsystemerror" so the task is automatically continueing.

Syntax

Program                                   'Beginning of program
       <Code>
       OnSystemError                      'Start of OnSystemError 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 OnSystemError                  'End of OnSystemError block<br>
       <Code>
End Program                               'End of program

Availability

All versions

Scope

Task

Limitations

Only one instance of ONSYSTEMERROR can appear in the system

Examples

OnSystemError
  catch 12055               'catch Missing SERCOS telegram error
    Print "Missing telegram(s): communication interrupted"
End OnSystemError

See Also