MC-Basic:ONERROR/zh-hans

From SoftMC-Wiki
< MC-Basic:ONERROR
Revision as of 02:38, 25 April 2017 by Chi (talk | contribs) (Created page with "{{Languages}} == 缩写 == == 格式 == <pre> Program 'Beginning of program <Code> OnError 'Start of OnError block {catch <...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
语言: [[::MC-Basic:ONERROR|English]]  • [[::MC-Basic:ONERROR/zh-hans|中文(简体)‎]]

缩写

格式

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

适用版本

所有版本

描述

ONERROR指令用于在任务中捕获并处理同步和异步错误,同步错误是由用户任务造成的,并由解释器检测到,而异步错误与特定的程序代码行无关,例如位置跟随误差。被ONERROR捕获的错误不会由TRY/FINALLY机制捕获。当错误被捕获时,指定的错误处理代码被运行并且任务被停止,任务状态处于4,通过CONTINUETASK命令来恢复任务执行。

Template:注意

类型

NA

取值范围

NA

单位

NA

默认

NA

使用范围

Task

限制

ONERROR仅捕获与定义它们的任务相关联的错误。

不允许嵌套ONERROR。

例子

OnError

catch 3017

print "Position Following Error"

System.motion = 0 'Stop all motion

killtask task2.prg

End OnError

参见