Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

PowerBook-G5

macrumors 65816
Original poster
Jul 30, 2013
1,244
1,183
I'm working on an AppleScript that allows me to create new reminders with a simple keystroke. I have it so that I can select the list to add it to, create a name, and then add a note to the reminder. For each window, there are two buttons: a cancel button, and a button that advances to the next step. The second button works just fine, but it's the cancel button that I can't figure out.

If I click on the Cancel button in the first window, it only advances to the next window, making me click the other Cancel button to quit running the script. I'd like to make the first Cancel button, when clicked, terminate the script. Any help would be appreciated!

Here's the code:
Code:
tell application "Reminders"
	
	(choose from list {"Personal", "Daily", "School", "AppleScript Tests"} with title ¬
		"Choose a list" with prompt "Choose a list in which to create a new reminder." OK button name "Select" cancel button name "Cancel" default items {"AppleScript Tests"})
	
	set mLA to result as text
	
	set mL to mLA
	
	set mN to the text returned of (display dialog "Enter a new reminder." default answer "" buttons {"Cancel", "Next"} with title "New Reminder" default button "Next")
	
	set mN to the text returned of (display dialog "Enter a note for the reminder." default answer "" buttons {"Cancel", "Create"} with title "New Reminder" default button "Create")
	
	tell application "Reminders"
		set mR to make new reminder in list mL
		set name of mR to mN
		set body of mR to mN
		
	end tell
	
end tell
 
The "cancel" button in choose from list does not generate an error like other dialogs, instead it returns false, so you just need to test for that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.