- 论坛徽章:
- 0
|
本帖最后由 jiangyuyun 于 2011-07-29 21:31 编辑
chain出错会报,chain(e)不会,要用monitor
banym1982 发表于 2011-07-27 17:44 ![]()
如果用monitor on-error的结构,未必能捕获到chain(e)的错误。
例如以下错误,Filea定义了usropn,但程序还未执行open Filea却先执行了chain(e) 1 Filea。此时:
fFilea if e disk usropn
d a s 2s 0
/free
monitor;
chain(e) 1 Filea;
if %error ;
// chain(e)产生的错误会在此处被处理
a = a + 1;
endif ;
on-error ;
// chain(e)产生的错误不会在此处被处理,但是如果第一句 a = a + 1出错,此时算数运算的错误控制会跳转到此处处理
a = a + 1;
endmon;
open Filea;
*inlr=*on;
/end-free
如果将程序中的chain(e)改为chain,那么一旦chain出错,才会跳转到on-error后的语句处理。此时,这里的if %error...endif是多余的。 |
|