Morthawt Posted December 29, 2013 Share Posted December 29, 2013 Am I right in assuming this is purely a time saving thing? Or is there some other aspect to this I am missing? Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
trancexx Posted December 29, 2013 Share Posted December 29, 2013 Functions became first class objects some time ago so you can do this: $Variable = Beep $Variable() Is that what you are asking about? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Morthawt Posted December 29, 2013 Author Share Posted December 29, 2013 (edited) Yes. The only real thing I could come up with is instead of always using ThisNewFunctionThatHasAReallyDescriptiveName(whatever) you could $go = ThisNewFunctionThatHasAReallyDescriptiveName $go(whatever) I am just trying to get a full understanding of these few new features so that I know where I am going with them and why. So is this purely a time saving thing or is there some important nuance I am missing of another reason this is good? Edited December 29, 2013 by Morthawt Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
JohnOne Posted December 29, 2013 Share Posted December 29, 2013 There has been lengthy discussions about the pros and cons of this ability when they were introduced into beta. I don't remember a link in dev chat, but worth having a peek, see if you can find it. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
trancexx Posted December 29, 2013 Share Posted December 29, 2013 I don't believe there has ever been any "cons". Unless there was somebody really retarded involved in discussion. Besides $Variable() existed since almost forever in the language. It was normally used for object variables to access default property/method: $Variable = ObjCreate("Shell.Explorer") ConsoleWrite($Variable() & @CRLF) ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JohnOne Posted December 29, 2013 Share Posted December 29, 2013 I don't believe there has ever been any "cons". Unless there was somebody really retarded involved in discussion. Just an assumption darlin, someone always pipes up with a negative. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Morthawt Posted December 29, 2013 Author Share Posted December 29, 2013 Thanks. I will have a look around. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted December 29, 2013 Share Posted December 29, 2013 Just an assumption darlin, someone always pipes up with a negative. "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation Link to comment Share on other sites More sharing options...
Morthawt Posted December 29, 2013 Author Share Posted December 29, 2013 I give up, I cannot find anything on it. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
Unc3nZureD Posted December 29, 2013 Share Posted December 29, 2013 Anyways it can be used to make some more difficult obfuscation methods Link to comment Share on other sites More sharing options...
JohnOne Posted December 29, 2013 Share Posted December 29, 2013 You can also pass a function to another function with great ease. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jchd Posted December 29, 2013 Share Posted December 29, 2013 and it rules out Call() (unless one is willing to make horrible computed function calls). This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
guinness Posted December 29, 2013 Share Posted December 29, 2013 Morthawt., A good example is _ArrayDisplay() where before the user function was being called by Call(), but I made a suggestion (in the MVP Forum) to change to a "first class object". Voila, you now see a real world example. JohnOne, I don't even remember a discussion taking place about this. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JohnOne Posted December 29, 2013 Share Posted December 29, 2013 I've got a lousy memory, but some things just stick in my head, one of the first beta's released post 3.8.1 I think. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
guinness Posted December 29, 2013 Share Posted December 29, 2013 Well it was first introduced here >> '?do=embed' frameborder='0' data-embedContent>> and discussed a little bit >here. But it's a good addition to the language and no one should doubt that! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JohnOne Posted December 29, 2013 Share Posted December 29, 2013 I'm probably remembering just reading about it from various threads. >Here's where I first seen it pop up. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Morthawt Posted December 30, 2013 Author Share Posted December 30, 2013 (edited) Morthawt., A good example is _ArrayDisplay() where before the user function was being called by Call(), but I made a suggestion (in the MVP Forum) to change to a "first class object". Voila, you now see a real world example. JohnOne, I don't even remember a discussion taking place about this. In the example code for _ArrayDisplay() I see no mention of using Call() I don't think I understand what you are getting at. I still do not understand the benefit of this first class object business with regards to this new function thing. What is the tangible benefit to using it? I am just trying to understand it so that I know when and why to use it. Edited December 30, 2013 by Morthawt Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 30, 2013 Moderators Share Posted December 30, 2013 Morthawt,Here is a concrete example, albeit simple, of how the new fucntionality works. Up until now, passing a function to another function had to be done like this:; Determine Autoit folder Global $sRootFolder = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) ConsoleWrite($sRootFolder & @CRLF) ; Define a function Func _FunctionToCall($sFile) ConsoleWrite($sFile & @LF) EndFunc ;==>_FunctionToCall ; Pass the function NAME to another function _ListFolder($sRootFolder, "_FunctionToCall") Func _ListFolder($sPath, $sFunctionToCall) If StringRight($sPath, 1) <> '\' Then $sPath &= '\' Local $hFind = FileFindFirstFile($sPath & "*.*") If $hFind < 0 Then Return SetError(1) Local $sFile While 1 $sFile = FileFindNextFile($hFind) If @error Then ExitLoop ; We need to use Call to run the function as all we have is the NAME Call($sFunctionToCall, $sFile) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< WEnd FileClose($hFind) EndFunc ;==>_ListFolderFor various reasons this was less than ideal - particularly if you used Obfuscator. We can now do it like this:; Determine Autoit folder Global $sRootFolder = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) ConsoleWrite($sRootFolder & @CRLF) ; Define a function Func _FunctionToCall($sFile) ConsoleWrite($sFile & @LF) EndFunc ;==>_FunctionToCall ; Pass the function itself to another function _ListFolder($sRootFolder, _FunctionToCall) ; The function is assigned to a variable in this function definition line Func _ListFolder($sPath, $hFunctionToCall) If StringRight($sPath, 1) <> '\' Then $sPath &= '\' Local $hFind = FileFindFirstFile($sPath & "*.*") If $hFind < 0 Then Return SetError(1) Local $sFile While 1 $sFile = FileFindNextFile($hFind) If @error Then ExitLoop ; We can now run the function directly $hFunctionToCall($sFile) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< WEnd FileClose($hFind) EndFunc ;==>_ListFolderDoes that help? 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...
martin Posted December 30, 2013 Share Posted December 30, 2013 @melba, Your example shows how the new way to use a function can work but it doesn't show any advantages. To use $hFunctionToCall($sFile) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< you would have to know what parameters should be passed to the function, ie know what the function is, and so you would be doing the same as writing _Functiontocall($File) so when would you want to use the new feature? There would need to be a requirement to call a function without being able to predict what that function would be at design time. Since that is easily covered using conditional statements the use of the new feature is not at all obvious to me yet. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Morthawt Posted December 30, 2013 Author Share Posted December 30, 2013 (edited) Yes I think so, unless I am mistaken you cannot use Call() in scripts you obfuscate because calls are needed during de-obfuscation right? So this offers a way to not break the script by enhancing it's ability to function in other environments. Are there any other environments where this would be crucial? So far I have: Can be used to shorten the code needed to shorten a long and repetative usage of a potentially long named function, to variableize it rather than make a shorter named function that passes the parameters to the long names function. Can be used inside a function in a way that the original function, when called, can have a function as part of it's parameters so the function will perform different actions based on the "next" function that was added as a parameter to the original function as in your example. EDIT: Although as the poster above has said, that will only work if the same number and context of parameters are the same, else you might be passing a file path as a message box type etc. Edited December 30, 2013 by Morthawt Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. 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