【发布时间】:2012-04-29 05:53:18
【问题描述】:
supposedlyGlobalVariable := "blah"
ARoutine()
{
localVariable := "asdf"
MsgBox, The global variable value is %supposedlyGlobalVariable%. The local variable value is %localVariable%.
}
^!X:: ;This assigns the hotkey CTRL + ALT + X to run the routine
ARoutine()
return
运行代码,结果为:
"The global variable value is . The local variable value is asdf."
documentation 声明:
变量范围和声明:局部变量除外 在函数中,所有变量都是全局的;也就是说,它们的内容可能是 由脚本的任何部分读取或更改。
为什么我的全局变量在函数中没有作用域?
【问题讨论】:
-
您是否将“
supposedlyGlobalVariable”指定为顶部的全局?如果在声明其值之前添加“Global supposedlyGlobalVariable”行,它将起作用。编辑:哦,我明白了,看起来你没有。
标签: autohotkey