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
-
lohill
- Posts: 770
- Joined: Tue Dec 08, 2009 6:37 pm
Post
by lohill » Thu Jan 07, 2010 3:10 am
I am having a difficult time understanding the true nature of dgData when used with a DataGrid. What actually are the components of an element of dgData? I can use a script such as the following with my DataGrid and look at individual elements in the IDE.
Code: Select all
put the dgData of group "DataGrid 1" into tData
If I follow that line with
I get the current price for the element whose index is 2.
But if I try
Code: Select all
answer tData[2][6] -- where 6 is the column containing the current price
I get nothing.
I guess my question is: Is tData a two element array or a three element array or something in between?
I ask this because I am looking for a way to add a new element to dgData using dgData rather than dgLine.
Thanks in advance for ant light you can shed on this.
Regards,
Larry
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
-
Contact:
Post
by FourthWorld » Thu Jan 07, 2010 3:21 am
All arrays in Rev are implemented as associative arrays, simple name-value pairs. So you'd get a value in tArray[2] only if the key to that element is the numeral "2".
-
lohill
- Posts: 770
- Joined: Tue Dec 08, 2009 6:37 pm
Post
by lohill » Thu Jan 07, 2010 5:15 am
All arrays in Rev are implemented as associative arrays, simple name-value pairs. So you'd get a value in tArray[2] only if the key to that element is the numeral "2".
Does that mean that dgData is a two dimensional array where the first element is an Index number and the second element is a string that names a column in the array and the combination of the two maps to a specifuc element in the grid?
Regards,
Larry
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
-
Contact:
Post
by FourthWorld » Thu Jan 07, 2010 6:26 am
Yes, I believe that's the case with the DG data.
-
trevordevore
- VIP Livecode Opensource Backer

- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
-
Contact:
Post
by trevordevore » Thu Jan 07, 2010 4:21 pm
Larry,
Richard is correct. The Data Grid numerically indexes the first dimension (that is the index referred to throughout the API). The 2nd dimension contains the names that you used when you populated the Data Grid. In the case of a Data Grid table this is typically just the names of the columns in your Data Grid but you are in no way restricted to just using the column names.
If you want to see exactly what the dgData looks like try this:
Code: Select all
dispatch "PrintKeys" to group "DataGrid"
This is a little helper command I added to print off the array since RevTalk has no built-in way of printing off arrays.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
lohill
- Posts: 770
- Joined: Tue Dec 08, 2009 6:37 pm
Post
by lohill » Thu Jan 07, 2010 6:29 pm
Interesting Trevor,
If you want to see exactly what the dgData looks like try this:
CODE: SELECT ALL
dispatch "PrintKeys" to group "DataGrid"
Does this command have limitations to the size of the grid it can handle? My grid with about 12 rows of 15 columns would not show but a small 3x3 grid appeared nicely both from the message box and under program control. The larger grid showed nothing from the message box and stepping from program control showed 'it' as 'handled' but the variable into which I was going to put the data showed nothing.
Anyway, thanks to your help and the help of others I'm beginning to get the hang of DataGrids.
Regards,
Larry
-
trevordevore
- VIP Livecode Opensource Backer

- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
-
Contact:
Post
by trevordevore » Mon Jan 11, 2010 4:49 pm
There is no size limitation. The 12x15 table should print off fine. Were you editing the Data Grid behavior script by chance? If so then it is possible you wiped out the script local variable that stores the Data Grid data. This would cause PrintKeys to show no results.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder