hmsSurprise Posted April 6, 2007 Share Posted April 6, 2007 I have not found any documentation for it but was wondering if there is support for something akin to function pointers. Something like: $fn = "myFunc" $fn() Old c/c++ habit, I guess. jh Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 6, 2007 Share Posted April 6, 2007 AutoIT doesn't do pointers, exactly, but you can do this with Execute(): For $n = 1 To 3 MsgBox(64, "Results", $n & " doubled is " & Execute("_DoubleIt(" & $n & ")"), 2) Next Func _DoubleIt($i) Return $i * 2 EndFunc ;==>_DoubleIt Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
hmsSurprise Posted April 6, 2007 Author Share Posted April 6, 2007 AutoIT doesn't do pointers, exactly, but you can do this with Execute(): For $n = 1 To 3 MsgBox(64, "Results", $n & " doubled is " & Execute("_DoubleIt(" & $n & ")"), 2) Next Func _DoubleIt($i) Return $i * 2 EndFunc ;==>_DoubleIt Thanks, at first I thought it wasn't working then I checked return value and saw that it did. However the MsgBoxs within the called functions did not show. Now I need a option like Tcl has to promote the called function to run at the current scope level. Don't suppose eval would work either... Thanks for the try. Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 6, 2007 Share Posted April 6, 2007 Huh! Sure enough, this change doesn't present the Msgbox from the function: For $n = 1 To 3 MsgBox(64, "Results", $n & " doubled is " & Execute("_DoubleIt(" & $n & ")"), 2) Next Func _DoubleIt($i) MsgBox(64, "_DoubleIt", "Input to function: " & $i) Return $i * 2 EndFunc ;==>_DoubleIt Found a reference in the help file under Execute to explain why: Remarks Environment, Files, Dir, Disk, GUI, InputBox, MsgBox, Misc, Network, Obj/COM, Process, Registry, Tray, WinKill functions implying deletion or modification will not be executed. They will set @error to 9999 and return "". Well, AutoIT is a scripting language, not a compiled language. You can't expect full C++ functionality from a less-than-100KB interpreter. Daddy always said "Learn something new every day." I just did. I'm done for the day... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
hmsSurprise Posted April 6, 2007 Author Share Posted April 6, 2007 I have a series of parameterless tasks and thought it would be handy if I could put the names of the ones I wanted to Execute in an array, then just check the return value. But it will be simple enough to add a few lines for each one I want to run. We tried. jh Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 6, 2007 Share Posted April 6, 2007 I have a series of parameterless tasks and thought it would be handy if I could put the names of the ones I wanted to Execute in an array, then just check the return value. But it will be simple enough to add a few lines for each one I want to run. We tried. jh Ooh... that sounded interesting! Like: #include <array.au3> $avResults = _ManyFuncs() Func _ManyFuncs() Local $avReturn[1] = [0] _ArrayAdd($avResults, _MyFunc1()) _ArrayAdd($avResults, _MyFunc2()) ; ... _ArrayAdd($avResults, _MyFuncn()) $avResults[0] = UBound($avResults) - 1 Return $avReturn EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
hmsSurprise Posted April 6, 2007 Author Share Posted April 6, 2007 Yes, or if Execute would have supported it , just fill an array with the name strings and in the param list of Execute, & the '()'. But beggars like me can't be choosy, and I am appreciating the firepower at hand. Gotta prod the boss for a donation when I get this all together. jh Link to comment Share on other sites More sharing options...
xcal Posted April 6, 2007 Share Posted April 6, 2007 What about something like... Dim $array[3] = ['func1', 'func2', 'func3'] For $i = 0 To 2 Call($array[$i]) Next Func func1() MsgBox(0, '', 'func1') EndFunc Func func2() MsgBox(0, '', 'func2') EndFunc Func func3() MsgBox(0, '', 'func3') EndFunc Or maybe I'm misunderstanding? How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
hmsSurprise Posted April 9, 2007 Author Share Posted April 9, 2007 Forgive the late reply but Yes, absolutely, that is it! I check the server for what is installed and gen a list for the user. Now I can use a group of checkboxes for services needed and stuff the list in an array. Boy howdy, we're coming up with more ways for me to get over my head in trouble every day. Thanks PsaltyDS! Best Regards, jh 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