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
Run the code and the result is:
"The global variable value is . The local variable value is asdf."
The documentation states:
Variable scope and declarations: With the exception of local variables in functions, all variables are global; that is, their contents may be read or altered by any part of the script.
Why does my global variable not have scope within the function?
supposedlyGlobalVariable" as Global at the top? If you add the line "Global supposedlyGlobalVariable" prior to declaring its value, it will work. EDIT: Oh, I see, it looks like you didn't.