Trying to get an array to make working buttons. [Script Update]

Ok, so i have this array that makes some GUI buttons and adds the right text to them. my problem is that i don't know how to get the functionality behind them using another array. here is what i have working and the beginning of what i thought would work:

var theButtonNameArray = new Array ("Start", "Resume", "Options");
var theButtonFunctionAction = new Array ("Level1", "Level1", "OptionsScreen");

    function OnGUI () {
    // Make a text field that modifies stringToEdit.        
        for (i = 0; i < theButtonNameArray.length; i++){
                if (GUI.Button (Rect ((Screen.width*.5)-(theButtonPositionWidth*.5), (Screen.height*.5)-(theButtonPositionHeight+theButtonSpace)*(i*3), theButtonWidth, theButtonHeight), theButtonNameArray _+ theButtonFunctionAction*));*_
 <em>_/*print("Loading Level!");*/_</em>
_*<p>this should be correct right? i'm still getting an error on the Application.LoadLevel or the print line saying: BCE0044: expecting :, found ';'.</p>*_

Try these: GUI Toolbar: GUI Grouping: GUI Layout has similar things, including a grid:

And there's probably other ways of doing it too.

Ahh, I've been trying to do something kind-of similar lately....actually not that much but oh well, I see what you're trying to obtain. I'm sure there's a 'clean'er way to do it, by storing 'function call'(is that what Deleguates are for???) or something.

An alternative is to store numerical value, instead of the methods themselves. Then switch() the lastButtonValue and call the desired functions.

OR - not recommended for obscure reasons, yet that could work: store the functions name as Strings in the second array then use eval().

var buttonNames = new Array("myButton1","myButton2","myButton3");
var buttonValues = new Array("myFunc1","myFunc2","myFunc3");

_*function myFunc1(){//user clicked myButton1;*_
_*function myFunc2(){//user clicked myButton2;*_
_*function myFunc3(){//user clicked myButton3;*_
_*<p>While purely theoretical, I guess this should/could works and create a button for every buttonNames and once clicked. eval() should transform the Strings+() from the array into: </p>*_