zuladabef 5 Posted January 24, 2020 Share Posted January 24, 2020 I had one massive .au3 file with a few Global variables and all Funcs were working until I split the Funcs across several .au3 files to organize things better. Now, I have a Main.au3 with all the #includes and Global variables. Now I am receiving warnings that the Global variables are "possibly used before declaration". I assumed that upon Go all Globals were seen by all Funcs and no warnings, nor errors would occur. Can you help me understand how Global and #include work a bit better? Are there some best practices I should be following. #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> #include <Array.au3> #include <IE.au3> #include <Excel.au3> #include <_ClickAndDragOnStuff.au3> #include <_ClickOnStuff.au3> #include <_ExcelStuff.au3> #include <_SetInputBoxes.au3> Opt("MustDeclareVars", 1) Opt("WinTitleMatchMode", 2) Global $sName = "ABCD" Global $sIntName = "XYZ" Global $sStartTime = "0800" Global $sEmdTime = "1000" Link to post Share on other sites
Nine 1,634 Posted January 24, 2020 Share Posted January 24, 2020 I assume you did not #include "Main.au3" in your secondary script ? The way to learn how to create a personal include is to go into "AutoIt3\Include" folder. Open one of the .au3 UDF file you are familiar with and look inside how it is made. You will see how the Global Vars are declared, and how Functions are written. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
zuladabef 5 Posted January 24, 2020 Author Share Posted January 24, 2020 Ah, okay... So, if I can use #include-once, then I can use #include<Main.au3> and the Globals are visible? Link to post Share on other sites
Nine 1,634 Posted January 24, 2020 Share Posted January 24, 2020 (edited) Yep that's it. You can include your main.au3 as many times as you have scripts, and it will be included only once. Read https://www.autoitscript.com/autoit3/docs/keywords/include.htm It will tell you the best way to declare your own include Edited January 24, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector GIF Animation (cached) Screen Scraping Link to post Share on other sites
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