Trouble telling AppleScript Studio app to quit depending on results

Hi,

I’ve got an AppleScript Studio app that works well, except that I can’t figure out how to tell it to quit depending on certain results. For example, the script presents a window where the user makes certain choices, then launches Extensis Portfolio and takes actions based on those window choices. However, if the user has forgotten to actually select images in the Portfolio catalog, I want to display a dialog (not a problem) and quit (big problem).

Here’s the actual code:


on clicked theObject	
	if name of theObject = "Claim" then
		set myJobNumber to (contents of text field "JobNumber" of window 1) as string -- 11/16/09: Get the job number from the window.
		set myShipDate to (contents of control "ShipDate" of window 1) -- 11/16/2009: Two-step approach to getting short date string from date picker.
		set myShortShipDate to short date string of (myShipDate as date)
		set myClient to (title of current menu item of popup button "Client" of window 1) as string -- 11/16/09: http://macscripter.net/viewtopic.php?id=5167
		set myClaimInfo to myClient & "." & myJobNumber & "." & myShortShipDate as string
		
		call method "close" of (window of theObject) -- 11/17/09: We're done with the selection window.
		
		tell application "Finder" -- 11/24/09: Had to go to the Finder to set the dialog box's title.
			display dialog "Client: " & myClient & return & "Job number: " & myJobNumber & return & "Ship date: " & myShortShipDate with title "Confirm claim information"
		end tell
		------------------------------------PORTFOLIO-----------------------------------------------
			tell application "Portfolio 8.1"
				activate
				set myDoc to get name of document 1 -- 12/2/09: Make sure that Current Images.fdb is the frontmost document in Portfolio.
				if myDoc is not "Current Images.fdb" then
					display dialog "Current Images.fdb is not open or is not the frontmost catalog in Portfolio. Please try again." buttons {"Cancel"} default button "Cancel"--THIS IS WHERE I WANT THE APPLESCRIPT STUDIO APP TO QUIT				
-- CODE CONTINUES ON WORKING WITH PORTFOLIO HERE, then ends with:
display dialog myFilenameList with title "Images claimed" buttons {"OK"} default button "OK" -- 11/24/09: Works!
			end tell
		end timeout
	else if name of theObject = "Cancel" then
		quit
	end if
end clicked

Thanks for any help you can provide. I’d also like the AppleScript Studio app to quit when Portfolio is finished doing its thing, but I’ve not come up with how to do that either.

try something like this

if myDoc is not "Current Images.fdb" then
set _dialog to (display dialog "Current Images.fdb is not open or is not the frontmost catalog in Portfolio. Please try again." buttons {"Cancel"} default button "Cancel") --THIS IS WHERE I WANT THE APPLESCRIPT STUDIO APP TO QUIT
if button returned of _dialog is "Cancel" then
	quit me
else
	-- CODE CONTINUES ON WORKING WITH PORTFOLIO HERE, then ends with:
	display dialog myFilenameList with title "Images claimed" buttons {"OK"} default button "OK" -- 11/24/09: Works!
	end tell
	 end timeout
	else if name of theObject = "Cancel" then
	quit me ------
end if

Budgie

Thanks Budgie, this worked perfectly! There certainly is a big difference between “quit” and “quit me” in AppleScript Studio.

Again, many thanks.

Kevin

There is no difference at all. The difference is the proper syntax of display dialog :wink: