When I run my program, it give me an error on line #58, bad argument : number expected, got string, I have no idea why. Can you?
Code: https://github.com/n...ster/rtos/rtgui
[Error]Number Expected, got string
Started by Mailmanq!, Mar 12 2013 12:05 PM
8 replies to this topic
#1
Posted 12 March 2013 - 12:05 PM
#2
Posted 12 March 2013 - 12:09 PM
no one is going to github just to look at your program. give what wrong, where you think what wrong. dont just send everyone your whole program in github
#4
Posted 12 March 2013 - 12:19 PM
LuaEclipser, on 12 March 2013 - 12:09 PM, said:
no one is going to github just to look at your program. give what wrong, where you think what wrong. dont just send everyone your whole program in github
LuaEclipser, on 12 March 2013 - 12:09 PM, said:
no one is going to github just to look at your program
#5
Posted 12 March 2013 - 12:21 PM
btw, best to put your menu in a table, and use a print table function, like this for your menu
small version of menu
NOTE: ignore the [size=whatever]
[size=4]Menu = {
[size=4]"X------X",
[size=4]"X X",
[size=4]"X------X"
}
[size=4]function printTable(table)
for i=1, #table do
print(table[i])
end
end
printTable(Menu)
UNTESTED; SHOULD WORKsmall version of menu
NOTE: ignore the [size=whatever]
#6
Posted 12 March 2013 - 12:25 PM
LuaEclipser, on 12 March 2013 - 12:21 PM, said:
btw, best to put your menu in a table, and use a print table function, like this for your menu
small version of menu
printTable(Menu)
[size=4]Menu = {[/size]
[size=4]"X------X",[/size]
[size=4]"X X",[/size]
[size=4]"X------X"[/size]
[size=4]}[/size]
[size=4]function printTable(table)[/size]
for i=1, #table do
print(table[i])
end
end
UNTESTED; SHOULD WORKsmall version of menu
printTable(Menu)
for k,v in pairs(menu) do print(v) endThis is also off topic. You are avoiding the error at hand and simply went off and are now lecturing him about how he should make his program. Let's focus on the problem.
#7
Posted 12 March 2013 - 02:09 PM
Well, the error is that you got the arguments for string.rep backwards, the string should be the first argument and the number the second.
Actually, iterating using a counter (like for i = 1, #tbl do) is faster than using pairs (it's too small to notice, but for larger tables - really larger tables - you may notice it). Also, pairs doesn't ensure that the table will be iterated in order, so it would be better to use ipairs.
SuicidalSTDz, on 12 March 2013 - 12:25 PM, said:
Not a fan of using arrays to read the contents of a table.
#8
Posted 12 March 2013 - 02:18 PM
I guess since ipairs returns three values (an iterator function, the table, and 0), it would be the superior choice, now wouldn't it.
I always take ipairs for granted
I still don't like using an array to iterate over the table. But meh, that's just me
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











