PerryRaptor Posted January 27, 2007 Share Posted January 27, 2007 Can AutoIT generate the name of a function? I have about a dozen functions that I want to call via one IF...EndIf loop nested inside a While...Wend loop.CommandArray[x]If XXXX == CommandArray[$get_x] then $FunctionName = "Function" & $get_x & "()"Sleep(1000)ContinueLoopEndIfFunc Function1().......................EndFuncFunc Function2()........................EndFunc Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 27, 2007 Moderators Share Posted January 27, 2007 Have you looked at Call()? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
PerryRaptor Posted January 27, 2007 Author Share Posted January 27, 2007 Just now I looked at Call() and I don't see how that will work. I had difficulty following the help file instructions and examples. Link to comment Share on other sites More sharing options...
BALA Posted January 27, 2007 Share Posted January 27, 2007 Just now I looked at Call() and I don't see how that will work. I had difficulty following the help file instructions and examples. That sounds a bit oxymoronic...Anyways, I don't think Call() can be used to find the function's name, since it requires the function's name to work. [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
PerryRaptor Posted January 27, 2007 Author Share Posted January 27, 2007 Easy...I'm from the planet OxyMoronIC The helpfile didn't make sense as a means to my desire. Link to comment Share on other sites More sharing options...
BALA Posted January 27, 2007 Share Posted January 27, 2007 (edited) Easy...I'm from the planet OxyMoronICThe helpfile didn't make sense as a means to my desire.Hence to what I said in my second paragraph/sentence: Anyways, I don't think Call() can be used to find the function's name, since it requires the function's name to work.There's probably another command that can be used. I sometimes also despise the help file's "vagueness" Edited January 27, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
Helge Posted January 27, 2007 Share Posted January 27, 2007 I'm not sure who's confused; if it's you or me, but you could please explain what you mean with the word "generate" ? Do you want to run a function, named by mixing strings and variables or is it something else ? Maybe something like this...$i = 2 Call("Function" & $i) If you're confused by how Call works, then this points out what I said about it earlier today or yesterday... Link to comment Share on other sites More sharing options...
PerryRaptor Posted January 27, 2007 Author Share Posted January 27, 2007 It is against the doctrine of planet OxyMoronIC to complain about AutoIT because it is free. Link to comment Share on other sites More sharing options...
PerryRaptor Posted January 27, 2007 Author Share Posted January 27, 2007 @Helge... I read your post regarding Call() too...I'd like to learn more about the command because your post leads me to believe there is more than can be done with it. I want the IF...EndIF to create the name of the function that matches the one in the CommandArray. After creating the FunctionName, e.g. Function7() execute it. Link to comment Share on other sites More sharing options...
BALA Posted January 27, 2007 Share Posted January 27, 2007 $get_x = 1 While 1 $FunctionName = "Function" & $get_x & "()" Call($FunctionName) $get_x = $get_x + 1 If $get_x = 12 ExitLoop EndIf WEnd Would that do it? [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
PerryRaptor Posted January 27, 2007 Author Share Posted January 27, 2007 @Bala... Doesn't work Link to comment Share on other sites More sharing options...
BALA Posted January 27, 2007 Share Posted January 27, 2007 (edited) Maybe if you change the "&"s to "+"s The theory is that it will set "Function1()" for $FunctionName and put that in the Call(). Then it will loop changing it 1 higher, so now "Function2()", and it'll do that until Function12(). Perhaps Call() doesn't work with the "()" Another option is to just take out the "Call()" part completely and leave it as: $get_x = 1 While 1 $FunctionName = "Function" & $get_x & "()" $FunctionName $get_x = $get_x + 1 If $get_x = 12 ExitLoop EndIf WEnd Edited January 27, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
PerryRaptor Posted January 27, 2007 Author Share Posted January 27, 2007 This works...I didn't need the "()" at the end when generating/creating the function name. $get_x = "One" While 1 $FunctionName = "Function" & $get_x Sleep(1000) Call($FunctionName) WEnd Func FunctionOne() MsgBox(0,"Function One", "this is Function #1") EndFunc Thanks everyone Link to comment Share on other sites More sharing options...
Xenobiologist Posted January 27, 2007 Share Posted January 27, 2007 Hi, For $i = 0 To 2 Call("_do" & $i) Next Func _do0() ConsoleWrite(0 & @CRLF) EndFunc Func _do1() ConsoleWrite(1 & @CRLF) EndFunc Func _do2() ConsoleWrite(2 & @CRLF) EndFunc So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 28, 2007 Moderators Share Posted January 28, 2007 From: Anyways, I don't think Call() can be used to find the function's name, since it requires the function's name to work.To: Maybe if you change the "&"s to "+"s The theory is that it will set "Function1()" for $FunctionName and put that in the Call(). Then it will loop changing it 1 higher, so now "Function2()", and it'll do that until Function12(). Perhaps Call() doesn't work with the "()" Another option is to just take out the "Call()" part completely and leave it as: $get_x = 1 While 1 $FunctionName = "Function" & $get_x & "()" $FunctionName $get_x = $get_x + 1 If $get_x = 12 ExitLoop EndIf WEndHmmm... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
BALA Posted January 28, 2007 Share Posted January 28, 2007 From:To:Hmmm... I misunderstood what the question the first time until it was clarified in a later post, it happens. [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com 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