AppleScript to AppleScript Studio Question

So, I have a script that works pretty well as a vanilla AppleScript. I have ported it over to AppleScript Studio and built a nib and all that. I left some Display Dialogs and some Choose from List lines of code. They work well in the new Studio App, except if someone clicks “Cancel”. Then I get an error. I’ve tried to put the erroring section in to a Try block…didn’t help.

How can I get this to work?

Here’s a portion of the code (without the try block):



on clicked theObject
	
	if the name of theObject is "Stop" then quit
	
	if the name of theObject is "Check Out" then
		
		
		tell application "Finder"
			set MasterProjectList to (name of every file of folder "Master Project Files" of folder Editorial)
			set f to {}
			set fname to {}
			-- set f to (choose file with prompt "Pick a FCP Project File to Check Out")
			
			set fname to (choose from list MasterProjectList with prompt "Pick a FCP Project File to Check Out")
			
			set f to (every file of folder "Master Project Files" of folder Editorial whose name is fname) as alias
			
			set originalPath to POSIX path of f

			
			--set originalPath to POSIX path of f
			
			if originalPath ends with "/" then set originalPath to text 1 thru -2 of originalPath
			




Etc. Etc. with code. The error comes up if I hit cancel on “Pick a FCP Project File to Check Out”.

I also tried to put a “if fname = false then quit” etc.

Hi,

there is no choose from list command in AppleScript Studio.
But you have better looking options in ASS e.g. with a text view in a new window

Hi Jacques,

very interesting, because it’s neither mentioned in the documentation nor in the dictionary

Stefan,

You’re not limited to the AS Studio stuff in AS Studio. You can use Applescript terms from any application that supports Applescript. Or, as in this case, from the Standard Additions osax.

What this means is that you can take shortcuts and use “choose from list” if you want to. It isn’t kosher according to the Aqua guidelines, but you CAN do it.

Thanks Kevin, I didn’t know that

Have you tried something like this?

if fname is false then error number -128 -- cancel