Referencing a single datagrid cell

Peter Haworth pete at
Tue Feb 1 20:25:59 EST 2011

Thanks for the clear explanation.  

For me, it's not the use of arrays that is the problem, I'm a fan of arrays.  My simple brain just has a hard time wrapping my head around when I can call the dg commands/functions directly, when I have to dispatch/send them, when I have to tag on "in zero seconds".  I have been bitten by that many times!  

On the other hand, the dgText is always easily accessible and I can turn it into an array if I need to.  I have some homegrown handlers that are pretty much the equivalent of the dg command/functions but accessing the dgText instead of internal dg arrays and so far they have worked well for me and I have not had to worry if the scripts that use them are in the datagrid group path or not.

Pete Haworth

On Feb 1, 2011, at 4:01 PM, zryip theSlug wrote:

> On Wed, Feb 2, 2011 at 12:29 AM, Bob Sneidar <bobs at> wrote:
>> Ok Peter helped me understand the GetDataOfIndex/SetDataOfIndex functions. I think when I read, "- Retrieves the internal array for key pIndex of the internal array in the data grid..." I just assumed that the returned value would always be an array. I see now that if you reference a column name for the second argument you get a value instead.
> Internally the datagrid works with arrays even if you populate with
> the dgText property.
> For populating a datagrid of 3 columns with the dgData property we
> could use a script such as:
> put "a1" into theData[1]["col1"]
> put "b1" into theData[1]["col2"]
> put "c1" into theData[1]["col3"]
> put "a2" into theData[2]["col1"]
> put "b2" into theData[2]["col2"]
> put "c2" into theData[2]["col3"]
> Now if you transpose this code as bricks or pieces of puzzle and
> encase each piece by index and column names you could get:
> theData[1]["col1"]["col2"]["col3"]
>                  a1       b1       c1
> theData[2]["col1"]["col2"]["col3"]
>                  a2       b2       c2
> Now let's join the col names and extract each index
> theData["col1"]["col2"]["col3"]
> 1             a1        b1      c1
> 2             a2        b2      c2
> Then you have a double entry table: the datagrid.
> Understand how working with arrays is one of the key to understand the
> datagrid object, I think. It make good sense why a name of a column
> (not the label) must be filled and unique: its just a key in an array.
> getDataOfIndex simply read the corresponding value in a double entry
> table such as you could do it in a spreadsheet, by using A2 or L2C1
> Best regards,
> -- 
> -Zryip TheSlug- wish you the best! 8)
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

More information about the Use-livecode mailing list