Run a block of code conditionally using if
.
if m < 30 write "Hello!"
Any number of lines of code can be controlled by if
, but
it is important to indent the code neatly. Any indented code will
only be run if the condition holds true.
The opposite condition can be used with else
.
if m < 30 write "Hello!" else write "Goodbye!"
If the code for an if
is short, it the whole
thing can be written on a single line by using
the word then
after the condition
if f then rt 99 else bk 99