guner7 Posted September 14, 2019 Share Posted September 14, 2019 Hi, Below is the code I've wrote long ago and ran it very frequent without any issue. I am doing some clean up recently and revisit the code just to find out that the ReplaceTheApp() function is able to access the variable I declared in Local. How can this possible while I didn't pass any variable into the function or declare the variable in Global? Local $UpdateInfo = IniReadSection(@AppDataDir & "\AutoUpdater.ini", "Update") Local $WorkingPath = $UpdateInfo[1][1] Local $AppName = $UpdateInfo[2][1] Local $WindowsTitle = $UpdateInfo[3][1] Local $Repository = $UpdateInfo[4][1] ReplaceTheApp() Run($WorkingPath & "\" & $AppName) Func ReplaceTheApp() SplashTextOn("Updating..", "Downloading new updates for installation, please wait..", 400, 60, -1, -1) FileDelete($WorkingPath & "\" & $AppName) InetGet("https://something.com/" & $Repository & "/download/" & $AppName, $WorkingPath & "\" & $AppName) Sleep(1000) SplashOff() EndFunc Thank you. siawpo 1 Link to comment Share on other sites More sharing options...
Musashi Posted September 14, 2019 Share Posted September 14, 2019 (edited) 11 hours ago, guner7 said: How can this possible while I didn't pass any variable into the function or declare the variable in Global? When you declare a variable in the global scope of a script (not in a function), then it is always Global, even if you use the keyword Local ! Edit : @guner7 There is only one global scope for all (script, includes), see example below : Main script (save as main.au3): ; Mainscript : Global $g_sText = 'This is a text' ConsoleWrite('@@ 1. $g_sText = ' & $g_sText & @CRLF) ConsoleWrite('! before #include -> IsDeclared("g_sIncludeGlobal") = ' & IsDeclared("g_sIncludeGlobal") & @CRLF) ConsoleWrite('< --> #include "Includescript.au3' & @CRLF) #include "Includescript.au3" ConsoleWrite('< --> #include Done' & @CRLF) ConsoleWrite('+ after #include -> IsDeclared("g_sIncludeGlobal") = ' & IsDeclared("g_sIncludeGlobal") & @CRLF) ConsoleWrite('@@ 3. $g_sText = ' & $g_sText & @CRLF) Include script (save as Includescript.au3) : ; Includescript : Global $g_sIncludeGlobal = 'some other text' ConsoleWrite('@@ 2. $g_sText = ' & $g_sText & @CRLF) ConsoleWrite('@@ $g_sIncludeGlobal = ' & $g_sIncludeGlobal & @CRLF) Edited September 14, 2019 by Musashi enhancement guner7 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 21, 2019 Moderators Share Posted November 21, 2019 7 hours ago, amzounslideslide said: Having said that, the overlay is nothing more than a scene so you should be able to reach in and get any function or variable you have assigned to the scene object. So, don't make the variables 'local'. Make them fields on the scene objects. I think you might want to check your Google Translate, as this made no sense. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now