Page 1 of 1
getDataOfLine Problem
Posted: Tue Aug 11, 2009 10:10 pm
by phaworth
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
Posted: Tue Aug 11, 2009 10:55 pm
by SparkOut
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.
Posted: Tue Aug 11, 2009 11:29 pm
by phaworth
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
Posted: Tue Aug 11, 2009 11:36 pm
by phaworth
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
Posted: Wed Aug 12, 2009 9:12 am
by SparkOut
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.
Posted: Wed Aug 12, 2009 4:40 pm
by trevordevore
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.
Posted: Wed Aug 12, 2009 4:44 pm
by phaworth
Thanks folks. I was indeed calling the script from outside the data grid group.
Pete
Posted: Wed Aug 12, 2009 4:49 pm
by phaworth
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?
Posted: Wed Aug 12, 2009 4:52 pm
by trevordevore
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).
Posted: Wed Aug 12, 2009 4:58 pm
by phaworth
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