Digisoul Posted July 24, 2013 Share Posted July 24, 2013 Hello there, Sorry for my lack of understanding, could anyone please show me the benefits or technical example of calling function through the variables ? I read the example posted by Melba23, but not understanding that how should I use this feature in my future scripts. Thanks in Advance. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Solution Mat Posted July 24, 2013 Solution Share Posted July 24, 2013 (edited) Functions are not first class objects, as they cannot be created at runtime (yet). This is the first step towards possibly implementing that in the future. The correct term would be second class, in a similar way to C's function pointers. A very common design pattern in other languages is a callback system like so: Local $a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] _EnumArray($a, MyCallback) Func MyCallback($v) ConsoleWrite($v & @LF) Return True EndFunc ;==>MyCallback ; Calls $Callback for each element in the array. ; If the callback returns FALSE then enumeration is stopped. ; Returns TRUE if the callback returned TRUE for all elements. Func _EnumArray($a, $Callback) For $i = 0 To UBound($a) - 1 If Not $Callback($a[$i]) Then Return False Next Return True EndFunc ;==>_EnumArray This is actually how the Enum* winapi functions work (though autoit handles this for you in WinAPI.au3 to return an array). This functionality was available previously with Call() and passing string function names. Advantages of this system are: AutoIt can check the functions for you, and fails with the correct error message if these are incorrect (e.g. incorrect number of parameters). AutoIt will also report an undeclared function name when you pass it to the function, rather than when you try and call it which could be somewhere further down the line making it difficult to trace the real problem. Works with obfuscator even if you use a variable rather than string literal. This is doing it properly. The main advantage you will see in every day use is that functions like HotkeySet can now take a function name as the second argument, rather than a string. This will report errors correctly as per point 2 above, though it appears that is not working correctly at the moment. I will report the bug now (assuming it is a bug as it means typos in keywords won't be reported as errors). If I'm honest, the main reason I like this change is the last point above: This is doing it properly and using string function names was not a good design choice in the first place (though was probably a lot easier to implement). Edited July 24, 2013 by Mat Digisoul 1 AutoIt Project Listing Link to comment Share on other sites More sharing options...
Digisoul Posted July 24, 2013 Author Share Posted July 24, 2013 Thanks for explanation Mat. it really help me to understand this feature. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
kylomas Posted July 25, 2013 Share Posted July 25, 2013 @Mat - In your example how does MyCallback return FALSE? 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...
Mat Posted July 25, 2013 Share Posted July 25, 2013 @Mat - In your example how does MyCallback return FALSE? kylomas MyCallback is just an example of any user supplied function, and _EnumArray would probably be in a library. The user might want MyCallback to only process elements until it finds a certain element, so it would return true until it reached the element and then return false. Since arrays are easy to pass around in AutoIt there isn't really a case where this provides new functionality and something you couldn't do before. It's just something you can use if you want to. AutoIt Project Listing Link to comment Share on other sites More sharing options...
kylomas Posted July 25, 2013 Share Posted July 25, 2013 @Mat - Thanks, thought I was going blind... 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...
trancexx Posted July 25, 2013 Share Posted July 25, 2013 Functions in AutoIt I left were first class entities. They were first class functions. This isn't arguable, not a bit. After I left Jon did what's called cherry picking (and later fine tuning through beta testing, something I wasn't allowed to do unfortunately). Appereance of some new func related built-in functions suggest that Jon doesn't understand the concept fully, or maybe doesn't use AutoIt much to see what's he doing wrong. He managed to reduce the feature to a level when it's valid to ask why it was added at all. This feature was meant to add new power to AutoIt as programming language and right now it's way not to use "string". My heart breaks when I see this. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 25, 2013 Moderators Share Posted July 25, 2013 trancexx,Then you should have stayed and helped develop AutoIt rather than resigning as a developer and continually bitching from the sidelines. We have all had more than enough of this never-ending carping from you - Jos has asked and now I am telling you to stop it. AutoIt is advancing in the direction that the original author wishes and if you do not like it then you know what you can do. M23 BigDod 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...
trancexx Posted July 25, 2013 Share Posted July 25, 2013 trancexx,Then you should have stayed and helped develop AutoIt rather than resigning as a developer and continually bitching from the sidelines. What I should have or have not is not up to you to say.We have all had more than enough of this never-ending carping from you - Jos has asked and now I am telling you to stop it. AutoIt is advancing in the direction that the original author wishes and if you do not like it then you know what you can do. M23I don't care about what "you" had enough of. I don't care about what Jos said and I don't care about what you say. You know what you two can do.To paraphrase you... All clear? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 25, 2013 Moderators Share Posted July 25, 2013 trancexx, All clear?Quite - I was expecting a response like that from you but I am disappointed to see my expectations confirmed. And I hope that it is equally clear to you that you have now had your final warning. So please no more complaining about the way AutoIt is developing - you had your chance to influence it, but that time has now gone. Let it drop. M23 BigDod 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...
Mat Posted July 25, 2013 Share Posted July 25, 2013 Functions in AutoIt I left were first class entities. They were first class functions. This isn't arguable, not a bit. After I left Jon did what's called cherry picking (and later fine tuning through beta testing, something I wasn't allowed to do unfortunately). Appereance of some new func related built-in functions suggest that Jon doesn't understand the concept fully, or maybe doesn't use AutoIt much to see what's he doing wrong. He managed to reduce the feature to a level when it's valid to ask why it was added at all. This feature was meant to add new power to AutoIt as programming language and right now it's way not to use "string". My heart breaks when I see this. Give Jon a chance, he's taken a big step back since when you left, so he can start moving forward on his own terms. So far he seems to be putting the time and effort in and I think he'll make progress. New features/functions have been almost entirely from MVP requests. Adding FuncName() is probably going to cause problems (or just return blank for anonymous functions) when/if functions do become first class, that's not a reflection on how much Jon understands what you were trying to do. You were ahead of your time, but refused to compromise, so everyone loses out unfortunately. And I think you are going to continue to see features you started implementing being "cherry picked" in a similar way to this I'm afraid. BigDod 1 AutoIt Project Listing Link to comment Share on other sites More sharing options...
Developers Jos Posted July 25, 2013 Developers Share Posted July 25, 2013 I don't care about what "you" had enough of. I don't care about what Jos said and I don't care about what you say. You know what you two can do. We knew already for a while that you don't care about anything else than yourself, but what really puzzles me is why you stick around moaning about it all like a little kid. Why this urge to prove whatever it is you want to prove or is it just that you take pleasure from all of this? Either way... grow up or simply go a play somewhere else. Jos BigDod 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
trancexx Posted July 25, 2013 Share Posted July 25, 2013 Give Jon a chance, he's taken a big step back since when you left, so he can start moving forward on his own terms. So far he seems to be putting the time and effort in and I think he'll make progress. New features/functions have been almost entirely from MVP requests. Adding FuncName() is probably going to cause problems (or just return blank for anonymous functions) when/if functions do become first class, that's not a reflection on how much Jon understands what you were trying to do. You were ahead of your time, but refused to compromise, so everyone loses out unfortunately. And I think you are going to continue to see features you started implementing being "cherry picked" in a similar way to this I'm afraid.It's not true I refused to compromise. Who told you that? If that's what you were told then you were being lied to.I trust Jon almost completely. He's extraordinary figure. I can understand reasons for all of his actions because there is much logic involved, even though our logic sometimes differentiates particularly when human relations are involved. It's only his dogs that scare me to death. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Administrators Jon Posted July 25, 2013 Administrators Share Posted July 25, 2013 It's not true I refused to compromise. Who told you that? If that's what you were told then you were being lied to. I did. You were asking me to de-MVP de-Dev you because I wasn't able to be around. I tried to talk you out of it by saying that I'd make time and as part of that I wanted to get a stable release out ASAP. I went though the changes, decided which ones I wanted to keep and which to cut - some permanently. Pages of text later I gave up after this comment: I may accept it for some things, but for thing that's really important to me I won't. Then I did as you asked an de-Deved you. And then I've since spent 6 hours a day for the last 4 weeks trying to make the extact feature set I asked of you to start with a reality. I was hoping that when you saw I was willing to get things moving and a release was actually going to happen that you'd help but I think it's a lost cause and I'm better off relying on myself - shit programmer that I am or not. Thread closed. Take it to PM if you wish but I'm sick this place today and I'm off out. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Recommended Posts