help with choosefile

ok, i’m making a program that prompts you to choose a file until you hit the cancel button in the choosefile prompt. When you hit cancel I want a prompt to come up asking if you want to empty the trash.
heres my code right now:

property file_name : path to desktop folder
property outputPath : path to trash
property inputName : "Desktop"
property outputName : "Trash"
property dialogPrompt : "Choose the file that you want to delete. Press cancel when your done deleting files. "
property confirmButton : "Move to " & outputName
property cancelButton : "Don't Move to " & outputName
property dialogButtons : {cancelButton, confirmButton}
repeat until (file_name is false)
	tell application "Finder"
		set file_name to (choose file with prompt dialogPrompt)
		display dialog ("Are you sure you want to delete" & file_name & "?") buttons dialogButtons default button confirmButton
		if button returned of result is confirmButton then
			move file ((file_name as string)) to outputPath
			if file_name is false then
				display dialog "Would you like to empty the trash now?" buttons {"Yes", "No"} default button "Yes"
				set trash_choice to button returned of result
				if trash_choice is "Yes" then
					tell application "Finder"
						empty trash
					end tell
				else if trash_choice is "No" then
					error number -128 --cancel
				end if
			end if
		end if
	end tell
end repeat

file_name is not false if you press cancel (that’s for choose from list). The script just quits.

That might be simplified a little, hendo. For example:

repeat
	try
		set f to choose file with prompt "Choose a file to delete. Press cancel when you're done deleting files." without invisibles
		display dialog ("Are you sure you want to delete " & f & "?") buttons {"Delete", "Don't Delete"} default button 1
		if button returned of result is "Delete" then tell application "Finder" to delete f
	on error number -128
		exit repeat
	end try
end repeat
display dialog "Would you like to empty the trash now?"
tell application "Finder" to empty

Thank you for that, Kai;

I didn’t know about: “on error number -128”; didn’t know I could specify it, so didn’t know how to trap a “user cancelled”.