Deleting the all the rows of a table

Hi,

I’ve been able to create and add data to a table. The contents of the table are loaded from a file and display as desired. If I select a new file the table clears and the new content is displayed.

I used the following to clear the table source so that new content doesn’t add to the bottom of previous content:

delete data rows of trackTableSource

The problem is that if I click in the table, then try to load a new file an error message pops up:
Can’t set text field “name” of window id 1 to text field “name” of window id 1. (-10006)

Click through the error message, the table clears and the new data is loaded.

Commenting out the “delete” line eliminates the error but the new data is just added to the end (the latter is expected as that was the point of the “delete”).

Adding a try block doesn’t help.

Is there a better (proper?) way to clear the data source for a table?

or is there something I need to do with regards to the click in the table before the new data is loaded?

Brad

I think you’ve probably indirectly answered your own question in your post… or at least given yourself a place to start troubleshooting this for yourself. The error you’re receiving appears to have nothing to do with the table or it’s data source. Instead, it appears that you have a line somewhere in your code that references the text field “name” incorrectly. Perhaps you’re trying to set the contents of a text field to the selected row contents, you’ve mistyped something, or you’ve forgotten to comment out some development-related code referencing a “name” text field? Considering the error you’ve posted, I’m guessing there’s something like this in your code somewhere…

set text field "name" of window id 1 to text field "name" of window id 1
--OR --
tell window id 1
	set text field "name"...
end tell

If this is not the case, then you’ll need to offer us more of your code up for inspection. Given the error you’ve posted, and the conflicting description of the problem, there’s little we can do to help you troubleshoot without access to what your code is really trying to do.

j

Sure enough, it was a rouge “name” should have been “trackName”.

Thanks,
Brad