Manipulating cells in a matrix
Posted: 2023-08-31 03:06:14
Some time ago Philip helped create a macro which ouputs an array of an arbitrary selection of cells. In an 8x8 matrix each cell is thus defind by a two-digit number representing row and column number of the cell:
Let‘s say the result is $out = ("00", "21", "24")
My question is: How can I do the inverse: How can I select the 3 cells, knowing there position in the matrix?
What I try to do is to manipulate the selection. For a simple case like inverting row and column this can of course be done by swapping within the push expression. But what about changing the row number, for example. I tried:
This worked. But when I tried to to do the same thing with the column number, like this
This did not work. Why is that?
Code: Select all
$doc = Document.active
$octals = Array.new
foreach $tblSel in $doc.tableSelections
foreach $cell in $tblSel.cells
$octals.push $cell.row & $cell.column
end
end
$out = $octals
Document.newWithText "$out"
My question is: How can I do the inverse: How can I select the 3 cells, knowing there position in the matrix?
What I try to do is to manipulate the selection. For a simple case like inverting row and column this can of course be done by swapping within the push expression. But what about changing the row number, for example. I tried:
Code: Select all
$octals.push $cell.column & (7-$cell.row)
Code: Select all
$octals.push (7-$cell.column) & $cell.row