getDataOfLine Problem

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

getDataOfLine Problem

Post by phaworth » Tue Aug 11, 2009 10:10 pm

Starting to get further inot data grida and having a problem with the above function. Here's the code:

Code: Select all

put the dgHilitedIndexes of group "TransactionList" into myLine
put getDataOfLine(myLine,"Amount") into myAmount
This compiles OK but thros an error at run time:

(Function: error in function handler) near "getDataOfLine", char 17

There is a column named "Amount" in the list. I got this code directly from the Data Grid manual.

Any ideas?

For now, I'm getting the data I want by accessing the dgText property of the data grid.

Thanks,
Pete

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Tue Aug 11, 2009 10:55 pm

At first glance I think you've left out the reference to the source of the data

Code: Select all

put getDataOfLine(myLine,"Amount") [insert "OF" <<source>> here] into myAmount
such as "of me" if this is inside the dgTemplate script or "of group <myDataGridName>"

HTH - if not, any more info and I (or someone) can take a closer look.

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Tue Aug 11, 2009 11:29 pm

I thought there was something missing! Looks like ther's an omission in the Data Grid manual since if missed off the group name as well (page 63).

Thanks,

Pete

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Tue Aug 11, 2009 11:36 pm

Whoops, replied too quickly!

I now have:

Code: Select all

put GetDataOfLine(myLine,"Amount") of group "TransactionList" into myTotalAmount
but I get a compilation error "(Commands: missing ',') near "into", char 57"

Anyone?

Pete

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Wed Aug 12, 2009 9:12 am

Sorry, I answered too quickly without checking as well. I was referring to the syntax of interrogating the dgProps as in:

Code: Select all

put the dgHilitedLines of group "TransactionList" into myLine
put the dgDataOfLine[myLine] of group "TransactionList" into myArray
put myArray["Amount"] into myAmount
I have a feeling the GetDataOfLine(theLine) function needs to work inside the DataGrid templates itself, otherwise I'm not sure. Sorry about the confusion anyway. The above will (in theory) work, if that helps.

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Post by trevordevore » Wed Aug 12, 2009 4:40 pm

GetDataOfLine is probably failing because you don't have it in the data grid group script or one of it's behaviors. GetDataOfLine is a function defined in the data grid itself. If you call GetDataOfLine from a card script then the function is not in the message path.
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

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Wed Aug 12, 2009 4:44 pm

Thanks folks. I was indeed calling the script from outside the data grid group.
Pete

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Wed Aug 12, 2009 4:49 pm

Also, thanks for the code. I had done something similar but accessing the dgText(myLine) and then grabbing the chunk I need out of it. Any advantage one way or the other between using dgText and dgDataOfLine?

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Post by trevordevore » Wed Aug 12, 2009 4:52 pm

dgText grabs all data from the data grid. the dgDataOfLine returns one particular record. dgDataOfLine will be faster. Also, dgDataOfLine returns an array and arrays can hold any type of data with worrying about whether or not that data contains the column separator (i.e. tab).
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

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Wed Aug 12, 2009 4:58 pm

Thanks Trevor. I think I will convert over to dgDataOfLine. I need to get column data like this quite frequently in my app so should be pretty simple to write a function passing in the group name and column name to get the contents.
Pete

Post Reply