if not (variable > 2) then
tell application "Safari" to activate
end if
That’s an odd usage though (you could just use a different operator, like Eelco did); Consider this instead:
choose file without invisibles
set {folder:isFolder} to info for result
if not isFolder then
-- If you choose a bundle (e.g. an application), you won't see this dialog
display dialog "That item is not a folder."
end if
Interestingly, testing if something’s true and branching if it’s not is minutely faster than testing if it’s not true and not branching if it isn’t! That is:
if (variable > 2) then
else
-- Do something.
end if
. is marginally faster than:
if not (variable > 2) then -- or any syntactical variant of this.
-- Do something.
end tell
The difference isn’t enough to make it worth doing in normal circumstances, but it can help in intensively repeating processes, such as sorts. I think that when testing if something’s not so, AppleScript tests if it is so and then ‘nots’ the result before deciding whether or . er . not to branch. :rolleyes: