atzoref Posted January 8, 2012 Posted January 8, 2012 Hi, My question is: If I declare a variables in the main func, is it automatic set it as a global variables so I can use it in the functions which called in the main func? In the other function I must declare if the variables is global so I can use them in the main func? Thanks
TheGeneral Posted January 8, 2012 Posted January 8, 2012 From the help file you could get that: Quote The difference between Dim, Local and Global is the scope in which they are created:Dim = Local scope if the variable name doesn't already exist globally (in which case it reuses the global variable!)Global = Forces creation of the variable in the Global scopeLocal = Forces creation of the variable in the Local/Function scopeYou should use Local or Global, instead of Dim, to explicitly state which scope is desired for a variable/constant/array.When using variables, the local scope is checked first and then the global scope second.Note that your code will be very disorganized with global variables. Try sending them as parameters (Const or ByRef) and returning the result/results.
Moderators Melba23 Posted January 8, 2012 Moderators Posted January 8, 2012 atzoref,You might find the Variables - using Global, Local and ByRef tutorial in the Wiki of interest. M23 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: Reveal hidden contents 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
MvGulik Posted January 8, 2012 Posted January 8, 2012 On 1/8/2012 at 8:58 AM, 'atzoref said: If I declare a variables in the main funcAutoIt has no special main, or other name, function. There is Root level code and Function level code. ... Although using a function as a "main" start-up function is not a bad practice. ... The rest seems already covered. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
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