After reading this excellent article on tables without using data sources I had high hopes for greater simplicity dealing with tables in AS Studio:
http://macscripter.net/articles/451_0_10_0_C/
I can do this:
property myList : {{"Macintosh HD", "Macintosh HD:"}, {"Users", "Macintosh HD:Users:"}, {"bwaldie", "Macintosh HD:Users:bwaldie:"}}
set theTable to table view 1 of scroll view 1 of window 1
set content of theTable to myList
However when I try to do the reverse, I don’t get my list back:
set myList to content of thetable as list
What i get instead is some sort of table array or data source that can’t be referenced by item c of item r of myList:
Can’t get item 2 of {|table column 1|:“Macintosh HD”, |table column 2|:“Macintosh HD:”}. (-1728)
How can I get my list back?
The way I have it set up is there is a table on a drawer. When the drawer is opened the 2-column table is set to the list. I want to set the list back to the edited version when the drawer is closed. Simple stuff really, no need for complicated table manipulations, which I was hoping to avoid.
Also, it would be great if there were also an easy way using this method to add rows and delete selected rows, but Ben’s article jumped from setting the contents of a table view to a list, to talking again about data sources. My understanding was this method was a (new) way to avoid data sources.
Thanks.
Edit: I figured out a work around – but still not as easy as I wanted and probably I’m missing something more fundamental about this new method.
set myList to {}
repeat with i from 1 to (count data rows of data source of thetable)
set this_row to data row i of data source of thetable
copy {content of data cell 1 of this_row, content of data cell 2 of this_row} to the end of myList
end repeat
Also, humble readers, please don’t forget the part about adding and deleting rows without a data source (here my work around goes back to a data source).
PS: I want to thank everyone for all the help recently. Cheers.