Droplets, Tables, and Repeat Problems

I’m new to AS Studio so I’m sure there must be something that I’m missing. I have tried all kinds of things to try to get a table to fill with file names dropped on the application icon. It seems like it doesn’t recognize theFiles information and it seems like the repeat function doesn’t work.

An application that I’m trying to somewhat mimic is FileRenamer 0.98
http://macscripter.net/news.php?id=4343_0_4_0_C, but I need my version to do different things.
Anyway, here’s the code that I’m having problems with.



property tableData : {{|fileNames|:"a"}, {|fileNames|:"b"}, {|fileNames|:"c"}, {|fileNames|:"d"}}

property tableList : {}

on open theFiles
	repeat with i from 1 to number of items of theFiles
		set this_item to item i of theFiles
		tell application "Finder" to set theName to name of this_item
		set end of tableList to {|fileNames|:(theName as string)}
	end repeat
	
	show window "fileWindow"
	
	
end open

on awake from nib theObject
	-- Create the data source
	set theDataSource to make new data source at end of data sources with properties {name:"fileList"}
	
	-- Create each of the data columns, including the sort information for each column
	make new data column at end of data columns of theDataSource with properties {name:"fileNames", sort order:ascending, sort type:alphabetical, sort case sensitivity:case sensitive}
	
	-- Make this a sorted data source
	set sorted of theDataSource to true
	
	-- Set the "name" data column as the sort column
	set sort column of theDataSource to data column "fileNames" of theDataSource
	
	-- Set the data source of the table view to the new data source
	set data source of theObject to theDataSource
	
		-- Add the table data (using the new "append" command)
	append theDataSource with tableList
end awake from nib

on idle theObject
	(*Add your script here.*)
end idle

I am able to populate the table using tableData as opposed to using tableList so I do know the table is working.

Thanks in advance for any help.

It could be that the “awake from nib” handler is being called BEFORE the “open” handler, therefore there is no tablelist to append to the table. I read the section on “awake from nib” in the AppleScript Studio Terminology Reference and it shows that “awake from nib” is handled very early. The “open” handler wasn’t mentioned so I don’t know when it is called in relation to the “awake from nib” handler.

Brad Bumgarner, CTA

I finally got it figured out and Brad you are correct. I populated the table in the on open handler and everything came together. I actaully found the answer in Apple’s Mailing Lists and I had the same exact problem that I could not find the answer in Xcode’s documentation. In fact, there’s not a whole lot about using the on open handler in the documentation.

Thanks for the reply.

No kidding. I just recently have been working on a droplet. I just kind of felt my way through the dark.

Glad you got it working.

Brad Bumgarner, CTA