Decker87 Posted July 24, 2008 Posted July 24, 2008 Hi everyone. I am new to this forum, but not new to AutoIT. I have written two functions which work together. One of them, "Ben", is recursive and makes a call to itself. The other, "Jerry", is not recursive but does make a single call to Ben, among other things. The problem I have is that for all intents and purposes, Jerry is all I need. He calls on Ben and returns the values I want. So is there a way to sort of "package" Ben inside of Jerry? So that I don't need to define both functions every time I use Jerry? To summarize: Func Ben(some parameters) blah blah Ben(some parameters) EndFunc Func Jerry(some parameters) some code more code Ben(some parameters) more code return some value EndFunc
weaponx Posted July 24, 2008 Posted July 24, 2008 You could but it would get ugly. You would have to add a flag parameter to "Jerry" that triggers a Switch statement within the function. Func Jerry($param1, $param2, $param3, $recurse) If $resurse Then Jerry($param1,$param2,$param3,TRUE) Else ;Non-recursive stuff EndIf EndFunc
Decker87 Posted July 24, 2008 Author Posted July 24, 2008 Yes. I actually do have that as part of my code for Ben, which is why I created Jerry to envelope him - so that the end user doesn't see or know about the flag parameter.
weaponx Posted July 24, 2008 Posted July 24, 2008 Yes. I actually do have that as part of my code for Ben, which is why I created Jerry to envelope him - so that the end user doesn't see or know about the flag parameter.Maybe just set a global variable: Global $recurse = true
crzftx Posted July 24, 2008 Posted July 24, 2008 A local variable would work fine. code code Jerry(14,34) code Func Jerry($var1, $var2, $ben = False) If Not $ben Then Jerry's code Else Ben's code (which may or may not implement $var1 and $var2) Jerry(0, 0, True) When it's finally time to exit Ben, do your final stuff and return Endif EndFunc
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