FANDOM


We will learn if statements.

Try this code:

set a to 5 --setting vars again...

set b to 6 --...

if a + b is 12 -- checking if a + b is 12. 5 + 6 is 11, not 12, so this doesn't work.

display dialog a & "+" & b & "=12!"--...

end if --ALWAYS END AN IF STATEMENT WITH THIS OR IT WILL NOT WORK!

Nothing will happen if you run the script. If you add more to it:

set a to 5

set b to 6

if a + b is 12

display dialog a & "+" & b & "=12!"

else --the previous test was false, so it goes straight to this

display dialog a & "+" & b & "=/=12!"

end -- you can just type "end" and the script automatically does the rest. cool?

Then something happens. You can also do this:

set a to 5

set b to 6

if a + b is 12

display dialog a & "+" & b & " is 12!"

else if a + b is smaller than 12 -- checks if it is smaller than 12. a + b is smaller than 12, so it stops here.

display dialog a & "+" & b & " is smaller than 12!"

else -- if both statements are false, it goes here.

display dialog a & "+" & b & " is bigger than 12!"

end

You can also put as many "else if"s as you want.

END OF LESSON 3. In PART 3-1, you will learn repeat commands. For now, bye!

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.