A script runs, want to stopit half way

Is there a way that i can stop a script half way through??? and can i do this using another script??

also can the script that i am tyrying to stop catch this and then save all the things i want to save. <–that but i know, but dont know if i can just say:

if script stopped then
my saveDetails()

Hi :slight_smile:

You can use the “try” statement, for exemple :

on run
		display dialog "Hello :-)" & return & "How are you ?" buttons {"Heu...", "Good !!!"} with icon 1
		--The error command for stopping the script
		if button returned of the result is "Heu..." then error "Ho... sorry :/"
	on error MsgErr
		--Here the alternative code or subroutine
		my Dlg(MsgErr)
	end try
end run

on Dlg(Txt)
	display dialog Txt with icon 2
end Dlg


Maybe a “repeat until” statement will work…