PELock Posted September 29, 2016 Share Posted September 29, 2016 I'm trying to use #OnAutoItStartRegister to modify the Global variable, but it seems it doesn't work, is that on purpose, that those callback functions cannot modify anything except in their own scope? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 29, 2016 Moderators Share Posted September 29, 2016 PELock, Which bit of "You cannot advertise payware on the forum" do you have problems understanding? I have removed the links in your sig, please do not replace them. 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: 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...
PELock Posted September 29, 2016 Author Share Posted September 29, 2016 Good you have removed them, but can you answer the question? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 29, 2016 Moderators Share Posted September 29, 2016 (edited) PELock, Post the code you have tried. M23 Edit: From my tests it seems that, as with all directives, the code is run before any code is executed - so all variables within the functions are treated as Local and any Global variables of the same name are ignored as they do not yet exist. Edited September 29, 2016 by Melba23 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...
PELock Posted September 29, 2016 Author Share Posted September 29, 2016 Sure: Global $a = 0 #OnAutoItStartRegister "init_a" Global $b = 0 #OnAutoItStartRegister "init_b" ConsoleWrite($a & @CRLF & $b) Func init_a() $a = 1 EndFunc Func init_b() $b = 2 EndFunc ConsoleWrite() outputs both 0 and 0, it seems like those values within callback functions are treated like local variables or am I missing something? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 29, 2016 Moderators Share Posted September 29, 2016 PELock, See my edit above. 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: 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...
PELock Posted September 29, 2016 Author Share Posted September 29, 2016 I understand the implication of this, but if that's true - isn't it a bug? I mean we have clear language syntax defined here that tells the compiler that $a & $b are global variables so the current behaviour is against the AutoIt language own definition? Am I wrong? I can live with that, but it just seems odd. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 29, 2016 Moderators Share Posted September 29, 2016 PELock, I do not see it as a bug - if the functions run before any code is executed then, as I stated above, the Global variables do not yet exist so how can they be modified? I will amend the Help file text to make this clearer. Of course, you could always make a "feature request" to suggest that the current behaviour be modified...... 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: 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...
kylomas Posted September 29, 2016 Share Posted September 29, 2016 Autoit does not use a compiler. PELock 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
PELock Posted September 29, 2016 Author Share Posted September 29, 2016 So the statements are valided only at the execution point? Howly cows, its pretty useful to me Ok, thank you for explanations. Link to comment Share on other sites More sharing options...
PELock Posted September 29, 2016 Author Share Posted September 29, 2016 So the solution to my problem is simple #OnAutoItStartRegister "init_a" #OnAutoItStartRegister "init_b" ConsoleWrite($a & @CRLF & $b) Func init_a() Global $a = 123 EndFunc Func init_b() Global $b = 345 EndFunc thnx guys Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 29, 2016 Moderators Share Posted September 29, 2016 PELock, Declaring Global variables within a function is usually regarded as pretty poor coding practice. And why do you need to use a function to assign a value to the variables? Why not declare them within the code as normal? ;#OnAutoItStartRegister "init_a" Global $a = 123 ;#OnAutoItStartRegister "init_b" Global $b = 345 ConsoleWrite($a & @CRLF & $b) 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: 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...
PELock Posted September 29, 2016 Author Share Posted September 29, 2016 (edited) I'm building an obfuscator. Well, already builded one, now I'm polishing it. I hope it's not another forbidden topic here. Edited September 29, 2016 by PELock Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 29, 2016 Moderators Share Posted September 29, 2016 PELock, Not at all. I still fail to understand why the #OnAutoItStartRegister functions are necessary, but no doubt all will become clear in due course. 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: 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...
PELock Posted September 29, 2016 Author Share Posted September 29, 2016 It's pretty neat feature in my opinion, I've been playing with AutoIt for like 3 weeks already and I really like the language, I have some problems with floating point numbers and their compatibility with other programming languages and ceiling/flooring functions, but I'm really surprised how well "equipped" AutoIt is (built-in functions). One thing I didn't know and didn't like are case insensitive string comparisons in If and Switch constructs. Oh and the boolean arithmetic is badly designed for someone who comes from assembler and C++ background, instead of standard operators like | & ^ I have to use functions, but I guess it's choices made back in the days. And for my purposes, the most missing feature is GOTO Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 29, 2016 Moderators Share Posted September 29, 2016 (edited) PELock, Quote the most missing feature is GOTO But GOTO is evil - has no-one ever told you? M23 Edited September 29, 2016 by Melba23 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...
PELock Posted September 29, 2016 Author Share Posted September 29, 2016 GOTO is just a jump and I'm used to have control over the code flow ;), even sometimes in C++ code I use goto, rarely but sometimes there's no other way and leaving flexibility in hands of the programmer is a good thing. But no worry I already thought of other solution to this problem. Btw is there any roadmap for new AutoIt features (like classes, language features?) or is it in frozen state? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 29, 2016 Moderators Share Posted September 29, 2016 PELock, Quote is there any roadmap for new AutoIt features 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: 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...
kylomas Posted September 29, 2016 Share Posted September 29, 2016 (edited) M23, Interesting read, thanks. Kylomas Edited September 29, 2016 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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