dufran3 Posted April 2, 2007 Share Posted April 2, 2007 (edited) Say I have a multi-dimensonal array like so: the 0th , is the display name of the item. The 1st is the Function name, and the 2nd is a general flag used later. How do i call the functions using a loop? What if one of the functions requires something passed like...the 3rd. The loop I would use to call them is below. I am trying to call the function name that is declared in the array. Dim $aPwners[3][3] = [ _ ['Ouch','_iOuch()','0'], _ ['Death','_iDeath()','0'], _ ['Pwn','_iPwn()','0'], _ ['Rawr','_iRawr($itemtobepassed)','0'] _ ]oÝ÷ Ù«¢+Ù½ÈÀÌØí¤ôÀѼÀÌØíAݹÉÍM¥é´ÄìÀÌØíAݹÉÍM¥é±Éɱ¥È($ÀÌØíAݹÉÍlÀÌØí¥ulÅtì±Ðì´ôôôôôôôQ¡¥Ì¥ÌÝ¡É$´ÑÉ她Ѽ±°Ñ¡Õ¹Ñ¥½¸¹µÑ¡Ð¥Ì¥¸Ñ¡ÉÉä°à¸¡}¥=Õ °}¥Ñ ¸¸¹Ñ¸¤!½Ü¼¤¼Ñ¡¥Ìü)9áÐ Edited April 2, 2007 by dufran3 Link to comment Share on other sites More sharing options...
xcal Posted April 2, 2007 Share Posted April 2, 2007 Global $array[3] = ['funcone', 'functwo', 'functhree'] For $i = 0 To UBound($array) - 1 Call($array[$i]) Next Func funcone() MsgBox(0, '', 'funcone') EndFunc Func functwo() MsgBox(0, '', 'functwo') EndFunc Func functhree() MsgBox(0, '', 'functhree') EndFunc How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
dufran3 Posted April 2, 2007 Author Share Posted April 2, 2007 Ok, I see. What if the function requires a parameter? like funcone? I changed it. Global $array[3] = ['funcone', 'functwo', 'functhree'] For $i = 0 To UBound($array) - 1 Call($array[$i]) Next Func funcone($title) ;<---- like here MsgBox(0, '$title', 'funcone') EndFunc Func functwo() MsgBox(0, '', 'functwo') EndFunc Func functhree() MsgBox(0, '', 'functhree') EndFunc Link to comment Share on other sites More sharing options...
xcal Posted April 2, 2007 Share Posted April 2, 2007 (edited) Would you not be able to just get $title from within the function? Or set a Global $title = 'whatever' before the function is called, and then just use $title inside the function? edit - Just had a glance at the Call function in the help file. Your answer for passing args is there. Edited April 2, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Pascal257 Posted April 2, 2007 Share Posted April 2, 2007 Would you not be able to just get $title from within the function? Or set a Global $title = 'whatever' before the function is called, and then just use $title inside the function?edit - Just had a glance at the Call function in the help file. Your answer for passing args is there. Actually calling a function with args is that way better...I don't like global variables ^^(After having one of my scripts cleaned from global variables that caused it no longer working ^^) Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted April 2, 2007 Share Posted April 2, 2007 Ok, I see. What if the function requires a parameter? like funcone? I changed it. Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
dufran3 Posted April 2, 2007 Author Share Posted April 2, 2007 (edited) I just ended up making another element with the "parameter" to pass it. Dim $aPwners[3][4] = [ _ ['Ouch','_iOuch()','0','parameter1'], _ ['Death','_iDeath()','0','parameter2'], _ ['Pwn','_iPwn()','0','parameter3'], _ ['Rawr','_iRawr','0','parameter4'] _ ]oÝ÷ Ù«¢+Ø)½ÈÀÌØí¤ôÀѼÀÌØíAݹÉÍM¥é´ÄìÀÌØíAݹÉÍM¥é±Éɱ¥È( ±° ÀÌØíAݹÉÍlÀÌØí¥ulÅt°ÀÌØíAݹÉÍlÀÌØí¥ulÍt¤)9áÐ( Edited April 2, 2007 by dufran3 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