Help- Errors and Not sure how to properly end

I keep getting error codes that it will not work or end properly. Also is there a way to restart the script or say move it back like if I choose one button leading me to another can I go back and if so how or do I have to restart the script?

Please Help! I want to perfect this script so I can do my work again!

Also, all apps besides “Productivity” are created automators workflows to just open things or block things.
I used “Productivity” because I would change this script to a workflow app but I can’t because I first have to have the scrip compile and it won’t because a Productivity.app isn’t created.

Thank You!



set return_value to display dialog "What would you like to do" buttons {"Be Productive", "Goof Off", "Exit"} ¬
	default button "Be Productive" with title "Be Productive"

set answer to button returned of return_value

if answer = "Goof Off" then
	set return_goof to display dialog "Why should you goof off?" buttons {"Finished My Work", "I Should Not Be Goofing Off"} ¬
		default button "I Should Not Be Goofing Off" with title "Goofing Off?"
set answer to button of return_goof
	if answer = "I Should Not Be Goofing Off" then
		tell application "Work" to activate

if answer = "Be Productive" then
	set return_prod to display dialog "Get Started!" buttons {"Okay" , "No"}¬
		default button "Okay" with title "Be Productive"
	set answer to button of reutnr_prod		
			if answer = "Okay" then
				tell application "Work" to activate
			if answer = "No" then
				tell application "Productivity" to quit 
				tell application "Productivity" to activate
	

	
if answer = "Exit" then
	set return_exit to display dialog "See you next boot up!" buttons {"Bye" , "Go Back"}¬
	default button "Wait" with title "Stop Script"
	
	set answer to button of return_exit
	
	if answer = "Go Back" then
		tell application "Productivity" to quit
		tell application "Productivity" to activate

Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)

This is what you want:



repeat
	display dialog "What would you like to do" with title "Be Productive" buttons {"Exit", "Goof Off", "Be Productive"} default button 3
	
	if the button returned of the result is "Goof Off" then
		display dialog "Why should you goof off?" with title "Goofing Off?" buttons {"Finished My Work", "I Should Not Be Goofing Off"} default button 2
		if the button returned of the result is "I Should Not Be Goofing Off" then
			tell application "Work"
				activate
			end tell
            exit repeat
		else if the button returned of the result is "Finished My Work" then
			exit repeat
		end if
		
	else if the button returned of the result is "Be Productive" then
		display dialog "Get Started!" with title "Be Productive" buttons {"No", "Okay"} default button 2
		if the button returned of the result is "Okay" then
			tell application "Work"
				activate
			end tell
            exit repeat
			
		end if
		
	else if the button returned of the result is "Exit" then
		display dialog "See you next boot up!" with title "Stop Script" buttons {"Go Back", "Bye"} default button 2
		if the button returned of the result is "Bye" then
			exit repeat
		end if
	end if
end repeat

Model: 20" iMac
AppleScript: 2.3
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)

Moved the topic to the appropriate forum :cool:

This controls the back with the cancel button:

repeat
	try
		set answer to button returned of (display dialog "What would you like to do" buttons {"Be Productive", "Goof Off", "Exit"} default button "Be Productive" with title "Be Productive")
		if answer = "Goof Off" then
			set return_goof to display dialog "Why should you goof off?" buttons {"Back", "Finished My Work", "I Should Not Be Goofing Off"} default button "I Should Not Be Goofing Off" cancel button 1 with title "Goofing Off?"
			if return_goof = "I Should Not Be Goofing Off" then
				tell application "Work" to activate
			else
				--finished code
			end if
			exit repeat
		else if answer = "Be Productive" then
			set return_prod to display dialog "Get Started!" buttons {"Back", "Okay", "No"} default button "Okay" cancel button 1 with title "Be Productive"
			if return_prod = "Okay" then
				tell application "Work" to activate
			else --if return_prod = "No" then--unneeded
				tell application "Productivity" to quit
				tell application "Productivity" to activate
			end if
			exit repeat
		else if answer = "Exit" then
			set return_exit to button returned of (display dialog "See you next boot up!" buttons {"Bye", "Go Back"} default button 2 with title "Stop Script")
			if return_exit = "Go Back" then
				tell application "Productivity" to quit
				tell application "Productivity" to activate
				error "Bye"
			else
				exit repeat
			end if
		end if
	end try
end repeat