gpt4 book ai didi

rebol - 捕获所有 Rebol VID 错误的有趣方法

转载 作者:行者123 更新时间:2023-12-01 13:32:18 25 4
gpt4 key购买 nike

我无意中发现了这一点,只是想确保这不是 Rebol 设计中的一个小故障。我有以下代码,似乎成功捕获了 VID 环境中的所有程序错误。

view layout [ 
across
label "Rebol Command:"
f: field [
do f/text
focus f
] return
button "Error 1" [
print this-is-an-error-1
]
button "Error 2" [
print this-is-error-2
]

time-sensor: sensor 0x0 rate 1000
feel [
engage: func [face action event] [
if action = 'time [
time-sensor/rate: none
show face
if error? err: try [
do-events
true ; to make the try happy
][
the-error: disarm :err
? the-error
; reset sensor to fire again
time-sensor/rate: 1000
show face
focus f
]
]
]
]
do [
focus f
]
]

最佳答案

这不是故障——do-events 确实是一个调度程序,它会一直运行直到出现错误。不过,我建议将错误处理程序与布局模型本身分离:

view/new layout [ 
across
label "Rebol Command:"
f: field [
do f/text
focus f
] return
button "Error 1" [
print this-is-an-error-1
]
button "Error 2" [
print this-is-error-2
]
do [
focus f
]
]

forever [
either error? err: try [
do-events
][
the-error: disarm :err
? the-error
focus f
][
break
]
]

关于rebol - 捕获所有 Rebol VID 错误的有趣方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45269486/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com