为什么定时器不能正确对待全局变量?
Why doesn't timer treat global variable correctly?
这会连续发送t
:
myVar := true
SetTimer, myLoop, 0
myLoop(){
if (true) {
Send, {t down}
}
}
#Persistent
但这没有任何作用:
myVar := true
SetTimer, myLoop, 0
myLoop(){
if (myVar) {
Send, {t down}
}
}
#Persistent
为什么? myVar
和 true
的计算结果都是 true
,所以我不明白为什么不同。
myVar := true
应该是:
global myVar := true
因为 global
必须明确声明。
这会连续发送t
:
myVar := true
SetTimer, myLoop, 0
myLoop(){
if (true) {
Send, {t down}
}
}
#Persistent
但这没有任何作用:
myVar := true
SetTimer, myLoop, 0
myLoop(){
if (myVar) {
Send, {t down}
}
}
#Persistent
为什么? myVar
和 true
的计算结果都是 true
,所以我不明白为什么不同。
myVar := true
应该是:
global myVar := true
因为 global
必须明确声明。