Having trouble with checkboxes linked to tables

Hi all! Hope someone replies.

I am an experienced perl programmer picking up on AppleScript Studio and Xcode…but having issues.

I have a table view. The first column i have placed NSButtonCell (so i can get a checkbox on the line.). The 3rd line is the order number to print. So, for each checkbox that is checked, the system will lookup the order and print it to a report.

Above the table view I have a “PRINT” button which should start the items printing to a report. Thing is, I do not want this button enabled unless the user has actually checked a box in the table…so i created it with the enabled flag checked OFF.

Here is my problem… I CANNOT get the associated status of the checkbox and KNOW which line that came from

I also am having issues after the person clicks all the buttons, going through the table and saying: Okay, here they clicked this row, lets get the 3rd cell and store that to be printed.

I know i am doing this the hard way.

PLEASE PLEASE PLEASE enlighten me.
ALSO, WILL SOMEONE PLEASE tell me the following: Does ALTERING anyting in the table change the assoicated datasource? IE: If the user clicks a checkbox, does the value in the table AND the datasource change or do I have to issue some command to update the datasource to the value that is now in the table view?

The examples on the net are NEVER what you need …sorry for the frustrated posting! I have been trial and error on this for days!

So, here is what i have:


if the name of theObject is equal to "process_checkbox" then
		
		log "STATE: '" & state of theObject & "'"
		
		set counter to count (every data row of the aDataSource)
		
		display dialog "TOTAL ROWS: " & counter

		-- disable the print button if there are no checked boxes

		set st_enabled to false
		
		repeat with i from 1 to counter
			set i to i - 1
			tell theTableView
				set selected row to i
                                --- this part fails...saying 
				if state of button "process_checkbox" of data row i is true
                                set st_enabled to true
                                -- later i would want to know what row this is...(row i) so i can get the column 3's value to print the report.
                                end if
			end tell
		end repeat
		
		set enabled of button "printselected" of window "MainWindow" to st_enabled
		
	end if

Though this is not related precisely to the original question, it is what I just found works to get the ‘checked items’ in a table view. Perhaps useful to others who stumble in here.
Your checkbox row (nsbuttoncell) is the leftmost column, column 2 is the name of your row.


on clicked theObject --when you press a button to perform action
	set mySelectedList to {}
	repeat with i from 1 to (count of data rows of myASKDataSource) --myASKDataSource is your linked datasource for the scroll list
		if contents of data cell 1 of data row i of data source of table view "x" of scroll view "y" of window "mainwindow" is true then
			set row_Enabled to contents of data cell 2 of data row i of data source of table view "x" of scroll view "y" of window "mainwindow"
			copy row_Enabled to end of mySelectedList
		end if
	end repeat
	choose from list mySelectedList --TESTING PURPOSES ONLY
end clicked