Global variable does not have global scope

前端 未结 4 2038
予麋鹿
予麋鹿 2021-02-13 04:42
supposedlyGlobalVariable := \"blah\"

ARoutine()
{
   localVariable := \"asdf\"
   MsgBox, The global variable value is %supposedlyGlobalVariable%.  The local variable v         


        
4条回答
  •  忘了有多久
    2021-02-13 05:09

    You just need to declare the variable as global inside your function

    supposedlyGlobalVariable := "blah"
    
    ARoutine()
    {
       global supposedlyGlobalVariable
       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
    

提交回复
热议问题