Difference between revisions of "MC-Basic:ONERROR"

From SoftMC-Wiki
Jump to: navigation, search
m (Miborich moved page Axystems:MC-Basic:ONERROR to MC-Basic:ONERROR: Global renaming of Axystems: namespace into (Main):)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
{{Languages|MC-Basic:ONERROR}}
 
{{MC-Basic
 
{{MC-Basic
 
|SHORT FORM=
 
|SHORT FORM=
Line 63: Line 64:
  
 
|SEE ALSO=
 
|SEE ALSO=
* [[Axystems:MC-Basic:ONSYSTEMERROR|ONSYSTEMERROR]]
+
* [[MC-Basic:ONSYSTEMERROR|ONSYSTEMERROR]]
* [[Axystems:MC-Basic:TRY ... END TRY|TRY ... END TRY]]
+
* [[MC-Basic:TRY ... END TRY|TRY ... END TRY]]
  
[[Category:Axystems:MC-Basic:Error Handling|ONERROR]]
+
[[Category:MC-Basic:Error Handling|ONERROR]]
 
}}
 
}}

Latest revision as of 02:30, 25 April 2017

Language: English  • 中文(简体)‎

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