array vs. table

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
drOrganized
Posts: 24
Joined: Tue Dec 04, 2007 7:02 pm

array vs. table

Post by drOrganized » Thu Oct 01, 2009 3:08 am

I am a bewildered novice again:

I would like to be able to add new columns to an existing table, or populate particular [row,column] places in a table, and am trying to learn the most efficient way to do this.

In the process, I have a couple of questions:

Is it possible to display a 2 dimensional array into a table? (When I try this I get an error.)
put myArray into field "myTable"

On the other hand can I put the contents of a table into an array variable:
put field "myTable" into myArray
so that I can then update myArray with more data?

Alternatively, is it possible to update the contents of a table with:
put data into field myTable [x,y]

Any suggestions appreciated...

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Thu Oct 01, 2009 1:34 pm

Hi drOrganized,

you need to change the array to a "normal" variable/list:
...
combine myArray by column
put myArray into fld "myTable"
...

Check "combine" and "split" in the docs (Rev Dictionary) to learn more about changing arrays to lists and vice versa.


Best

Klaus

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: array vs. table

Post by sturgis » Fri Oct 02, 2009 3:36 am

drOrganized wrote:I am a bewildered novice again:

I would like to be able to add new columns to an existing table, or populate particular [row,column] places in a table, and am trying to learn the most efficient way to do this.

In the process, I have a couple of questions:

Is it possible to display a 2 dimensional array into a table? (When I try this I get an error.)
put myArray into field "myTable"

On the other hand can I put the contents of a table into an array variable:
put field "myTable" into myArray
so that I can then update myArray with more data?

Alternatively, is it possible to update the contents of a table with:
put data into field myTable [x,y]

Any suggestions appreciated...

Code: Select all

On your "populate a row/column" method question, if I recall correctly, rev treats a table as a regular old field that contains lines and items.  So if you did 

set the itemDelimiter to tab 
-- needed because the table field uses tab as the delim char.
-- if I remember right, the itemdelimeter isn't global, so once the handler is done, it reverts to the default, in this case, the default item delimiter is comma. 

put "This is the 3rd cell of line 1" into item 3 line 1 of fld "myField" 
-- puts the data into the item and line position you specify
you should be able to specify where you want it.

drOrganized
Posts: 24
Joined: Tue Dec 04, 2007 7:02 pm

Array v Table

Post by drOrganized » Fri Oct 02, 2009 3:50 am

Klaus & Sturgis,

Many thanks!

Dr. O~

Post Reply