4 posts
Posted 15 November 2012 - 06:14 AM
I have attempted to create a GUI program but when i call my 'option' function only the first time it will enter store the variable into my table. The other times it doesn't enter nor does it overwrite the original variable in the table.
http://pastebin.com/UNN3vdvaMy program is there and any help as to my problem is much appreciated.
19 posts
Location
Home
Posted 15 November 2012 - 07:05 AM
Is it supposed to say hight? It's height
Edit: 2nd line
4 posts
Posted 15 November 2012 - 07:47 AM
Thank you, i must have overlooked that, i have updated the code as to make it easier to read and fix the spelling errors. Again, any help as to my problem would be much appreciated.
2088 posts
Location
South Africa
Posted 15 November 2012 - 09:28 AM
You call detect() after your write(progs[1], progs[2]) etc. Is that not the problem?
4 posts
Posted 15 November 2012 - 10:59 AM
No, I believe the problem is that the first time I run the option function it places 'pos' in the 'progs' table in the 'optno' position (at that time 1) but when it runs again for the second option (optno is now equal to 2) it fails to add the pos to the second position in the table; it fails to add anything to the table as a whole. Is it possible to do what i'm trying (insert into a table using local variables from a function) and if so what am I doing incorrectly. The printing of [1] and [2] from the table is merely there as that is my evidence that the second variable is not being added to the table. The detect function is what causes the error in my program as it cant find a second position in the 'progs' table.
8543 posts
Posted 15 November 2012 - 11:17 AM
Try declaring the progs table as an empty table and not specifying the position to insert the value in the table.insert call.
4 posts
Posted 15 November 2012 - 11:38 AM
I'm still having the problem of the variable 'pos' not being entered in the table. when printing progs[1] and [2] only the first value is shown which leads me to believe that the variable is still not being stored in the table. I tried using an empty table and not specifying the position in the insert call but i'm still having the same problem.
997 posts
Location
Wellington, New Zealand
Posted 15 November 2012 - 11:50 AM
Write only prints the first argument.