SorryButImaNewbie Posted April 22, 2015 Posted April 22, 2015 Hello! Can someone please explain to me the difference between these 2 functions? Func Example1() Function EndFunc Func Example2() Call("Function") EndFunc Just because I used to "call" some of my functions without the Call function, I'm sure that I miss something, but for me it looks like they do the same thing. Thank you!
caramen Posted April 22, 2015 Posted April 22, 2015 Function = Function Call = Function + Parameters optional My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
SorryButImaNewbie Posted April 22, 2015 Author Posted April 22, 2015 Thank you for the help! It's still not a 100% clear to me. I gave parameters to functions before, without Call. Like this: Local $TopUpName = "TopUpHUFKiadási(sztornó)_" & ControlGetText("PDFCreator 1.", "", "[CLASSNN:ThunderRT6TextBox5]") ;1. PDF RenamePDF($TopUpName) ;2. PDF $TopUpName = "" & $TopUpName & "(2)" RenamePDF($TopUpName) ;3.PDF Local $TopUpName = "TopUpHUFKiadásiSzámla(sztornó)_" & ControlGetText("PDFCreator 1.", "", "[CLASSNN:ThunderRT6TextBox5]") RenamePDF($TopUpName) ;4.PDF $TopUpName = "" & $TopUpName & "(2)" RenamePDF($TopUpName) Or do you mean, that If I use call then giving parameter is optional? How would something that needs parameter would run without them?
MikahS Posted April 22, 2015 Posted April 22, 2015 (edited) It is not optional, the failure return value of Call states: Failure: sets the @error flag to 0xDEAD and @extended to 0xBEEF if the function does not exist or invalid number of parameters. to make a Function call you can do it a couple ways: Local $test = False Example($test) ; simple function call passing 1 parameter Func Example($bool) If $bool = False Then MsgBox(0, "Test", "1 Parameter = " & $bool) EndFunc Or Local $test = True Call("Example", $test) ; using call to call the function with 1 parameter Func Example($bool) If $bool = True Then MsgBox(0, "Test", "1 Parameter = " & $bool) EndFunc All clear? Edited April 22, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
SorryButImaNewbie Posted April 22, 2015 Author Posted April 22, 2015 Thank you @MikahS! I know how to call a function (now I used both your above methods in my scripts), but I don't know whats the difference? Maybe more importantly, when should I use Call("FunctionName") and when should I just simply use FunctionName()?
Solution jchd Posted April 22, 2015 Solution Posted April 22, 2015 (edited) Also: Local $fct = ConsoleWrite $fct("Hello!") Call offers only one unique possibility: passing arguments in CallArgArray Edited April 22, 2015 by jchd 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)
javiwhite Posted April 22, 2015 Posted April 22, 2015 The call function can be handy when you have multiple functions with similar naming conventions ex: #include <GUIconstants.au3> $gui = GUIcreate("Test",400,400) $button1 = GUICtrlCreateButton("1",10,10,380,80) $button2 = GUICtrlCreateButton("2",10,110,380,80) $button3 = GUICtrlCreateButton("3",10,210,380,80) $button4 = GUICtrlCreateButton("4",10,310,380,80) GUISetState(@SW_SHOW) while 1 switch GUIGetMsg() Case $Button1,$Button2,$button3,$button4 $mouse = GUIGetCursorInfo() Call("func" & GUIctrlRead($mouse[4])) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func func1() msgbox(0,0,"Func1 called!") EndFunc Func func2() msgbox(0,0,"Func2 called!") EndFunc Func func3() msgbox(0,0,"Func3 called!") EndFunc Func func4() msgbox(0,0,"Func4 called!") EndFunc Regards Javi SorryButImaNewbie 1 give a man an application, and he'll be frustrated for the day, Teach him how to program applications and he'll be frustrated for a lifetime.
SorryButImaNewbie Posted April 22, 2015 Author Posted April 22, 2015 Thank you guys, for all of your help! I can say I learnt something today
MikahS Posted April 22, 2015 Posted April 22, 2015 (edited) For one, as jchd stated you can use a special array to pass arguments, like so: Local $aArgs[4] $aArgs[0] = "CallArgArray" ; required, otherwise the array won't be recognized as containing argmts $aArgs[1] = "I am a string parameter" $aArgs[2] = 50 $aArgs[3] = True Call("Example", $aArgs) Func Example($str, $int, $bool) MsgBox(0, "test", "string is: " & $str & @CRLF & _ "Int is: " & $int & @CRLF & _ "Bool is: " & $bool) EndFunc ;==>Example In my experience, I've only ever used it with functions that have many parameters, with an array like above. Otherwise, I just use the normal function call like so: Local $test = "hi" Example($test) Func Example($text) MsgBox(0, "", $text) EndFunc Edit: Good to hear. Edited April 22, 2015 by MikahS SorryButImaNewbie 1 Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
SorryButImaNewbie Posted April 22, 2015 Author Posted April 22, 2015 Thank you Master @MikahS! MikahS 1
MikahS Posted April 22, 2015 Posted April 22, 2015 (edited) It is my pleasure, @SorryButImaNewbie. Edited April 22, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
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