rizaado Posted June 18, 2015 Posted June 18, 2015 (edited) Hello. What is the aim of the #Region II:#include <MsgBoxConstants.au3> Func func1 () Return True EndFunc #Region I(call function with parentheses) MsgBox($MB_SYSTEMMODAL, "", func1()) #EndRegion #Region II(call function without parentheses) MsgBox($MB_SYSTEMMODAL, "", func1) #EndRegionI know that #Region II func1 returns itself by reference(its address) to MsgBox(nothing to see but fact).I am going to prove what I said before:#include <MsgBoxConstants.au3> Func func1 () Return True EndFunc Global $varFunc1 = func1 MsgBox($MB_SYSTEMMODAL, "", $varFunc1())What is the aim of calling function without parentheses? Give example. Thank you... Edited June 18, 2015 by rizaado
Moderators Melba23 Posted June 18, 2015 Moderators Posted June 18, 2015 rizaado,Welcome to the AutoIt forums.I think you have answered your own question - you use the function name without parentheses to assign it to a variable. One advantage is that you can then pass this variable as a parameter to another function which can then internally call whatever function was assigned to the variable - look at the use of $hUserFunction in _ArrayDisplay to see this in action.I am afraid that you will have to wait for someone more knowledgeable than me to get more info than that.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
rizaado Posted June 18, 2015 Author Posted June 18, 2015 (edited) Melba23, thank you once again for your comment but if someone wants to continue discussing this topic try on I will be waiting. I think I understand my misunderstood before. Some days I have professional deviation... I think that there are parts of the documentation that must be updated and must be written for the first time. I offer my services... Edited June 18, 2015 by rizaado
Malkey Posted June 18, 2015 Posted June 18, 2015 ..... What is the aim of the #Region II:.... #Region II(call function without parentheses) MsgBox($MB_SYSTEMMODAL, "", func1) #EndRegion....My understanding is there are two way to call a function ( maybe 3 ways when using Execute):-"function name" followed by parentheses; and,Call ( "function name" [, param1 [, param2 [, paramN]]] ).In all cases the "function name" may be stored in a variable.An example.#include <MsgBoxConstants.au3> func2(MsgBox, func1) ; The two parameters are names of functions. #region II(Is not calling a function when without parentheses) MsgBox($MB_SYSTEMMODAL, "2", func1) ; Meaningless - just a function name #endregion II(Is not calling a function when without parentheses) #region III(function names without parentheses as parameters) MsgBox($MB_SYSTEMMODAL, "3", func1, MsgBox, Chr) ; More meaningless function names. #endregion III(function names without parentheses as parameters) Func func2($sBuiltInFunc, $Func) $sBuiltInFunc($MB_SYSTEMMODAL, "1", $Func()) ; Function name in variable with following parentheses, calls that function. Return True EndFunc ;==>func2 Func func1() Return True EndFunc ;==>func1
jaberwacky Posted June 19, 2015 Posted June 19, 2015 I guess you could go this route too.; the practices you see here aren't exactly always the best ; only meant for demonstration purposes #include <Array.au3> Const $numbers[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Const $numbers_by_two = Map($numbers, MultByTwo) _ArrayDisplay($numbers_by_two) Func Map(Const $list, Const $function) Local Const $u_bound = UBound($list) Local $new_list[$u_bound] For $i = 0 To $u_bound - 1 $new_list[$i] = $function($list[$i]) Next Return $new_list EndFunc Func MultByTwo(Const $number) Return $number * 2 EndFunc Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
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