Stop AppleScript

Hello!

I have multiple IF conditions in my script and i am wondering how to stop the script after first condition match (IF contains "Yes")?

tell application "Safari"
	tell front document
		set _text to its text
	end tell
end tell

if _text contains "Yes" then
	return "Yes"
end if

if _text contains "No" then
	return "No"
end if

Is there something like "stop script" ?

Hey Kirill,

Return performs that function.

If it's in a script the script is terminated.

If it's in a handler the handler is terminated, and control is returned to the script.

-Chris


tell application "Safari"
   tell front document
      set _text to its text
   end tell
end tell

if _text contains "Yes" then
   return
else if _text contains "No" then
   # Null
end if
1 Like

Thank you for clarification, Chris :+1: