How to use if and if else in AppleScript?

How to use if and if else in AppleScript?

In this example, we first set up a variable, x, then set that variable equal 20. Now when we run our if statement, the number 10 is compared to the variable. In this case, 10 is not greater than 20, so the boolean will be false.

How to know if a statement is in AppleScript?

The great thing about AppleScript is that it’s so human readable. If you simply read this script out loud, you’ll be able to tell exactly what it does. Here’s the rundown: Given that 10 is not greater than 20, the second statement will be returned. Your result should look something like this:

What happens if the first if is false in AppleScript?

If that proves true, the first return statement will be run and the script will terminate (no further steps are taken). However, if that statement proves false, the first else if is tried, then the second and finally, if none of those prove true, the last else kicks in and returns a statement about it not being the weekend yet.

What happens if you run 10 < 1 in AppleScript?

If we flip that equality symbol around and run “10 < 1”, “false” is returned. This goes way beyond numeric expressions, pretty much any statement that AppleScript is able to evaluate should work as well. Here’s a quick check of the current day of the week, which returns “true”.

How to check if a statement is true in AppleScript?

To try it out, try typing in an equality statement right into AppleScript Editor and running it. As you can see, the compiler evaluated the statement, “10 > 1”, and correctly returned “true”. If we flip that equality symbol around and run “10 < 1”, “false” is returned.

Can I set a global variable with this AppleScript?

Can I set a global variable with this applescript? on runme (message) if (item 1 of message = 145) then set x to item 2 of message else if (item 1 of message = 144) then set y to item 2 of message end if if (item 1 of message = 145) then return message else set y to x * 8 return {item 1 of message, y, item 3 of message} end if end runme