PDA

View Full Version : Add, Remove item from table



Unknown 2010
03-05-2009, 05:32 AM
Hi,

To Add item to a table I use:
Table[Table.Count(Table)+1]="item"

For removing item I use:
Table.Remove(Table, 1)


But sometimes I got error .:huh

Imagine Programming
03-05-2009, 05:50 AM
Hi,

To Add item to a table I use:
Table[Table.Count(Table)+1]="item"

For removing item I use:
Table.Remove(Table, 1)


But sometimes I got error .:huh

You named the table "Table", this is already a table which contains the table functions... You have overwritten those functions. The next should work


tblName={}
tblName[Table.Count(tblName)+1]="item"

Table.Remove(tblName, 1)

Unknown 2010
03-05-2009, 06:14 AM
i got error also
attempt to concentrate field `?' (a nil value)

RizlaUK
03-05-2009, 06:28 AM
you must make sure the table and table item exist, and like CB said, you should prefix variable names

t or tb = table
n or num = number
s or str = string