PDA

View Full Version : some Questions for arrays and tables


Sie Tjin Kian
04-12-2005, 06:55 AM
Hi there,
1. How can I define multidimension arrays?
2. How can I define an array like the SQLite Plugin Command SQLite.QueryToTable, where I can access the data through a table in another table?
Is there any Plugin or Workaround to show a table in AMS with more than one column? I don't want to create an HTML Page!

Hope you understand my questions and thanks a lot in advance. Greez Tjin :D

TJ_Tigger
04-12-2005, 08:53 AM
Hi there,
1. How can I define multidimension arrays?
I like to think of multidimensional arrays as tables within tables. When you define a row in a table rather than assigning a string or numerical value, you can define it as a table. Like this


mdArray = {};
mdArray[1] = {name = "Worm", location = "Michigan"};
mdArray[2] = {name = "JimS", location = "Oregon"};
mdArray[3] = {name = "yosik", location = "Israel"};
mdArray[4] = {name = "Derek", location = "Bristol"};
mdArray[5] = {name = "Tigg", location = "Iowa"};

-- the information can then be accessed by doing this.
for i,v in mdArray do
sName = mdArray[i]["name"];
sLoc = mdArray[i]["location"];
Dialog.Message("Information", sName .. " is located in ".. sLoc);
end



2. How can I define an array like the SQLite Plugin Command SQLite.QueryToTable, where I can access the data through a table in another table?

see the above on creating a table within a table.


Is there any Plugin or Workaround to show a table in AMS with more than one column? I don't want to create an HTML Page!

Hope you understand my questions and thanks a lot in advance. Greez Tjin :D

There is not a plugin at this time that allows you to show the contents of an array within AMS. A HTML table seems to work very well at this time, you could create a tabular or csv text file and then put the contents into a paragraph object. I have also used multiple List Boxes to create a grid like area on the screen to populate data from a table. Not the cleanest or easiest thing to do but it works well.

Oh, as far as a plugin, you could store data in an XML file and then potentially open that file in Excel or a csv file for that matter and use LuaCOM or File.Run to open in Excel as well.

HTH Tigg

Sie Tjin Kian
04-20-2005, 02:14 AM
Hi TJ_Tigger,
thats exactly what I want, great - thanks! :D

mdArray = {};
mdArray[1] = {name = "Worm", location = "Michigan"};
mdArray[2] = {name = "JimS", location = "Oregon"};
mdArray[3] = {name = "yosik", location = "Israel"};
mdArray[4] = {name = "Derek", location = "Bristol"};
mdArray[5] = {name = "Tigg", location = "Iowa"};

-- the information can then be accessed by doing this.
for i,v in mdArray do
sName = mdArray[i]["name"];
sLoc = mdArray[i]["location"];
Dialog.Message("Information", sName .. " is located in ".. sLoc);
end

I have also tried to use listboxes for tables, but its very complicated! Maybe this will be a feature in future? I need to access the table elements and so I can't use HTML pages.
Thanks a lot, Tjin

S0mbre
05-28-2008, 12:57 AM
Somewhere in this forum I've read that a parser for CSV (comma-separated) tables would be a boon for the DataGrid Plugin. So I quickly made this tool that is able to export a CSV file into an AMS double-dimensioned array (rows / cols).

Features:


import CSV file and read into AMS string
raw CSV preview
parser function that returns a double array (rows by cols), number of rows and columns
LuaCom feature that exports the output result into Microsoft Excel (opens up Excel and fills in the data)


6556