Login  Register

How to change value in Results table instead of insert

Posted by Peter van Loon on Apr 10, 2014; 10:01pm
URL: http://imagej.273.s1.nabble.com/How-to-change-value-in-Results-table-instead-of-insert-tp5007271.html

Hi,

I tried to change an existing value in the Results Table by the macro function: setResult("Column", row, value). This works, the value of the given row and column is changed the it behaves like an insert. All rows from the given row number and all rows below 'move' to the next row. The last row disappears.

I checked this by setting the values manually by a simple macro:

macro " Set Results table [s]" {
rowIndex = getNumber("rowIndex", 0)
setResult("Comment", rowIndex,"rowIndex: "+rowIndex+" nResults:"+nResults);
}


First I filled the table with 6 values from rowindex 0..6.
Results Table:
1 rowIndex: 0 nResults:0
2 rowIndex: 1 nResults:1
3 rowIndex: 2 nResults:2
4 rowIndex: 3 nResults:3
5 rowIndex: 4 nResults:4
6 rowIndex: 5 nResults:5
7 rowIndex: 6 nResults:6


Then I added again rowindex 2.
Results Table:
1 rowIndex: 0 nResults:0
2 rowIndex: 1 nResults:1
3 rowIndex: 2 nResults:7
4 rowIndex: 2 nResults:2
5 rowIndex: 3 nResults:3
6 rowIndex: 4 nResults:4
7 rowIndex: 5 nResults:5


The last row disappeared, rowindexes 2..5 moved to the next row, rowindex 2 was filled with the new string.

Is there a way to change values of Results table and not insert a value?
I was thinking of filling and updating an array and at last fill the Results table rows one by one from this array but I think there must be a better way.

Regards,
Peter