GoogleDude Posted December 16, 2018 Share Posted December 16, 2018 So I have created a so-called 'master/main' include that basically has a ton of udfs that I have collected over time that I commonly use in my many projects. An issue I have running into is I am looking to set some global $vars in my main script that are used in my master include. I tried setting them as globals in my main script but they dont seem to carry over to my include. Its as though the include is read and $vars are processed before my main script is read at compile time. When I try to compile my main script it complains that $vars in my master/include have not been defined yet when they have been in my main project script. If that makes sense. Hope that makes sense and thanks for any feedback. ~GD Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 16, 2018 Moderators Share Posted December 16, 2018 GoogleDude, It sounds to me as if you need to recast your entire "main/include" philosophy! But to deal with the immediate problem: the code of any include file is inserted into the main script at the point of the #include directive, so if you declare the Global variables before that point they should be visible within your includes. M23 GoogleDude 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
GoogleDude Posted December 16, 2018 Author Share Posted December 16, 2018 Yes I agree with your 'you need to recast your entire "main/include" philosophy!' part. I have become accustomed to what I think are some bad scripting habits and introduce some if not a lot of the misc issue I end up having. Thanks for the immediate problem part. I always thought that includes needed to be at the top of my script before the global $vars. ~GD Link to comment Share on other sites More sharing options...
Nine Posted December 16, 2018 Share Posted December 16, 2018 (edited) Good programming practices require that #include should be self-sufficient. If you need to have some global vars declared for your include to work properly (and they should be at the very minimum), you should declare them directly in the include, not in the calling script. Information between the main script and the include script should always be passed thru function parameters. Edited December 16, 2018 by Nine GoogleDude 1 “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 Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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