cherdeg Posted February 18, 2009 Share Posted February 18, 2009 (edited) Hi altogether,Please assume to have at least two au3-Files, one compiling to the "main-executable" (containing the overall program skeleton) and one "include-file" (containing the functions called by the main-executable). Here an example of the construct:"main.au3":CODE#include <Array.au3>#include <includes.au3>Global $s_OStemp = @TempDirGlobal $s_WinDir = @WindowsDirGlobal $s_WinSysDir = @SystemDirshowdirs()Exit"includes.au3":CODEFunc showdirs()Local $arrDirectories[3]$arrDirectories[0] = $s_OStemp$arrDirectories[1] = $s_WinDir$arrDirectories[2] = $s_WinSysDir_ArrayDisplay($arrDirectories)EndfuncIf I CTRL+F5 main.au3, I get 3 warnings: "WARNING: $s_OStemp, $s_WinDir, $s_WinSysDir: possibly used before declaration." Now for my question:I thought, when I would select GLOBAL scope when first declaring my variables, they would be visible also from within every function (in contrary to the LOCAL scope where every variable is only visible within the function it was declared in). Am I wrong? Do I do something the wrong way? Would I have to call the showdirs-function with parameters like in "showdirs($s_OStemp, $s_WinDir, $s_WinSysDir)"? Are there other ways to have omni-present variables?My understanding in this regard is a bit...hmmm...hazy. Please help me to clarify the facts.Regards,Chrisp.s.: The helpfile could be a bit more...helpful regarding this topic. Also the listed example is quite...hmmm...worthless (for me). Edited February 18, 2009 by cherdeg Link to comment Share on other sites More sharing options...
BrettF Posted February 18, 2009 Share Posted February 18, 2009 Think of an #include line as shoving the included file right there. What comes first? The function or the declaration... Declare them as global in the include, and it should work correctly. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
cherdeg Posted February 18, 2009 Author Share Posted February 18, 2009 (edited) Think of an #include line as shoving the included file right there. What comes first? The function or the declaration... Declare them as global in the include, and it should work correctly.Cheers,BrettINCREDIBILE, MAESTRO!That easy life can be. It may not be the cutest way, but simply moving my declarations to above the includes solved my problem completely. I would have done as you advised, but I'm doing quite a large tool consisting of about 10 different includes. If I had to declare every global variable in every file, maintaining the variables alone would drive me crazy...Never the less: THANK YOU VERY MUCH for this simple solution.Regards,Chris Edited February 18, 2009 by cherdeg Link to comment Share on other sites More sharing options...
KJohn Posted February 18, 2009 Share Posted February 18, 2009 INCREDIBILE, MAESTRO!That easy life can be. It may not be the cutest way, but simply moving my declarations to above the includes solved my problem completely. I would have done as you advised, but I'm doing quite a large tool consisting of about 10 different includes. If I had to declare every global variable in every file, maintaining the variables alone would drive me crazy...Never the less: THANK YOU VERY MUCH for this simple solution.Regards,ChrisMove the Global declarations to a location before the actual #include statements. That way your problem will be solved without having to move them to (each of) the include file(s). Link to comment Share on other sites More sharing options...
cherdeg Posted February 18, 2009 Author Share Posted February 18, 2009 (edited) Move the Global declarations to a location before the actual #include statements. That way your problem will be solved without having to move them to (each of) the include file(s).Did you read my answer to BrettF (the one you actually quoted)? I "bold'ed" the relevant part. Thanks even so.EDIT: BTW, Your Diskmax-Tool seems to be quite cool. Are the sources open? Edited February 18, 2009 by cherdeg Link to comment Share on other sites More sharing options...
KJohn Posted February 18, 2009 Share Posted February 18, 2009 (edited) Did you read my answer to BrettF (the one you actually quoted)? Thanks even so.Ouch.. Didn't read the last post properly after going through the rest of the thread. My mistake.. Edited February 18, 2009 by Koshy John 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