Arrrghmatey Posted July 19, 2005 Share Posted July 19, 2005 Can you have the same function name, but different required args? I had Func function(arg1, arg2) ..... EndFunc and Func function(arg1, arg2, arg3) ..... EndFunc but it came up with errors. Just curious if this is possible or ever will be? Link to comment Share on other sites More sharing options...
JSThePatriot Posted July 19, 2005 Share Posted July 19, 2005 To my knowledge you cant overload functions. What exactly would you need this option for? Maybe there is another 'clean' solution. If not maybe a 'dirty' one JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
blindwig Posted July 19, 2005 Share Posted July 19, 2005 Can you have the same function name, but different required args?You can make certain parameters optional by giving them a default value:Func function(arg1, arg2, arg3=0) ..... EndFuncNow function could be called with (1,2) or (1,2,3). If called with just (1,2) then arg3 would contain a value of 0 (the default value set in the header)You can also use the macro @NumParams to see how many parameters were given to a function when it was called. My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
seandisanti Posted July 19, 2005 Share Posted July 19, 2005 Can you have the same function name, but different required args?I hadFunc function(arg1, arg2) ..... EndFuncandFunc function(arg1, arg2, arg3) ..... EndFuncbut it came up with errors. Just curious if this is possible or ever will be?<{POST_SNAPBACK}>overloading is not necessary with autoit because of the ability to have optional arguments and default values for arguments Link to comment Share on other sites More sharing options...
/dev/null Posted July 19, 2005 Share Posted July 19, 2005 Can you have the same function name, but different required args?but it came up with errors. Just curious if this is possible or ever will be?You can have optional paramters in your functions, like this:func myfunc($a, $b, $c=-1) endfuncThen you can call it like this:myfunc(1,2) myfunc(1,2,3)CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * 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