How do I select a row in a TableView from within a script

Hello all,

I have been all over trying to find an answer to this.

In my script I have a button, that when pressed, should modify a cell in a certain row (specifically the last row that was added) within the code, not by the user.

After looking around, I came up with this. I have no idea if this is the right way to do it.


set numRows to the number of data rows in theDataSource
set rowIndex to numRows - 1
set thisRowIndex to call method "indexSetWithIndex:" of class "methods" with parameters {rowIndex}
call method "selectRowIndexes:byExtendingSelection:" of class "methods" with parameters {thisRowIndex, no}

set theRows to selected data rows of theTable as list

-- Do something with the row


Any ideas?

Thank you Jacques, it worked perfectly!