Posted 28 October 2012 - 05:18 AM
I'm not sure what the problem is, but I'm having issues with using a certain function within a table. It's a menu, and when you select the item, it should open a file and display the contents. The function that does this works just fine. Though I'm trying to give the function call inside the table an argument as well, and that messes it up. When I have it in the first code below, it accesses the page right on the program's startup, instead of just opening the menu and waiting until I select the proper option instead. When I select said option, it gives me the "Can't cocantanate between string and nil" or whatever it is exactly on the showPage function. The menu displays perfectly, though. Below is the code that gives me this problem.
However, when I do it like this:
Then it works. I can do it this way, sure. But with the several options I would have, it would require me to have many lines of code that I feel I do not need (3 per option, and it would add up quickly), given I can figure out how to make the first code work correctly.
So, if anyone could help me with this, it would be greatly appreciated. Thanks in advance!
[1] = { dispText = "examplepage", selH = showPage("examplepage1") }
function activateSel( menu ) -- Activates when you hit enter on a selection, in this case, the "examplepage" option.
menu[select].selH()
end
However, when I do it like this:
[1] = { text = "examplepage", selH = showExampleOnePage }
function showExampleOnePage()
showPage("examplepage1")
end
Then it works. I can do it this way, sure. But with the several options I would have, it would require me to have many lines of code that I feel I do not need (3 per option, and it would add up quickly), given I can figure out how to make the first code work correctly.
So, if anyone could help me with this, it would be greatly appreciated. Thanks in advance!