PDA

View Full Version : Tables and files



xry
10-15-2009, 04:03 PM
Hi.
Now I had another problem. I create a table like the follow:


new_table = {};
new_table[1] = {item1="Item 1", item2="Item 2", item3="Item 3"};
new_table[2] = {item1="Item 4", item2="Item 5", item3="Item 6"};

and use


TextFiles.WriteFromTable("C:\\TestTable.txt", new_table, false);

to write the table to a file, but I get a 0 Kb file. While using


TextFiles.WriteFromTable("C:\\TestTable.txt", new_table[1], false);

I get the trick, but of course write only the element [1] of the new_table.

I'm totally newbie and I think the problem is that I create
a table for each new_table element, right?
Can someone help me?

Thanks
xry

IdeasVacuum
10-15-2009, 07:35 PM
Yes, essentially what you are doing there is creating tables within a table. This is permitted by Lua Script but apparently not supported by the AMS WriteFromTable function, so you need to use a loop and write to file (append) from each table.

xry
10-16-2009, 07:03 AM
Thanks, IdeasVacuum. I'll try to use the XML object, that seems interesting.

RizlaUK
10-16-2009, 09:04 AM
access the table like:

TextFiles.WriteFromTable("C:\\TestTable.txt", new_table[1], false);

or use the JSON plugin to write the complete table to file

http://www.indigorose.com/forums/showthread.php?t=27910&highlight=JSON