SetDataOfLine and Repeat--I'm missing something
Posted: Mon Dec 04, 2017 12:13 am
Hi,
I'm working with datagrids in the form style. It is just a little demo stack to see how to add across rows. I have text fields "SmallNumber", "BigNumber", and "TotalNumber". I have the datagrid script populate SmallNumber and BigNumber from my array of data. Then, it adds them together and places the answer in the text field TotalNumber. I wanted to save the contents of the field TotalNumber back to the array under the column/key called "CombinedEventTotal" that is already created--but whose element is empty at the moment.
I believe SetDataOfLine will do what I want. I can successfully do it one by one not using a repeat.
Thus, my trouble might be the repeat or the getting of the text out of the text field in the repeat process.
Here is how I used SetDataOfLine where it works without a loop. I have the code in the behavior script. Then, I have to click on each text field "TotalNumber" after that each answer is saved to the array.
When viewing printkeys data all is good and updated in the array.
Now here's where I have problems.
This takes the value for Record 1 for text field "TotalNumber" and puts it in all records for key "CombinedEventTotal" So, for my numbers 11 is written to all records in the array. The text fields still show the correct math as expected.
My Data looks like this in the text fields.
1 10 11
2 20 22
0 30 33
and like this in the array data
1 10 11
2 20 11
0 30 11
Thank you for pointers to what I'm forgetting,
I'm working with datagrids in the form style. It is just a little demo stack to see how to add across rows. I have text fields "SmallNumber", "BigNumber", and "TotalNumber". I have the datagrid script populate SmallNumber and BigNumber from my array of data. Then, it adds them together and places the answer in the text field TotalNumber. I wanted to save the contents of the field TotalNumber back to the array under the column/key called "CombinedEventTotal" that is already created--but whose element is empty at the moment.
I believe SetDataOfLine will do what I want. I can successfully do it one by one not using a repeat.

Thus, my trouble might be the repeat or the getting of the text out of the text field in the repeat process.
Here is how I used SetDataOfLine where it works without a loop. I have the code in the behavior script. Then, I have to click on each text field "TotalNumber" after that each answer is saved to the array.
Code: Select all
##Works to transfer field text to an array column/key element
on mouseUp pMouseBtnNum
if pMouseBtnNum is 1 then
## did they click on the text field?
if the short name of the target is "TotalNumber" then
## Update internal value in data grid
SetDataOfLine the dgLine of me, "CombinedEventTotal", the text of the target
end if
end if
end mouseUp
Now here's where I have problems.
Code: Select all
on mouseUp
repeat with theLineNo = 1 to the dgNumberOfLines of group "DataGrid 1"
## Get text value for each row
put the text of field "TotalNumber" into tTheLineSolution
dispatch "setDataOfLine" to group "DataGrid 1" with theLineNo,"CombinedEventTotal",tTheLineSolution
end repeat
end mouseUp
My Data looks like this in the text fields.
1 10 11
2 20 22
0 30 33
and like this in the array data
1 10 11
2 20 11
0 30 11
Thank you for pointers to what I'm forgetting,