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."
该文档指出:
变量作用域和声明:除函数中的局部变量外,所有变量都是全局的;也就是说,脚本的任何部分都可以读取或更改它们的内容。
为什么我的全局变量在函数内没有作用域?