Condition judgment.
IF THEN
If it would like
to do the different work by a condition,
how should it be done?
By
program, condition judgement with 'IF THEN' statement is done.
10 input
a
20 if a=100 then print "Pefect"
run
? 100 (input any
numerical value from keyboard here)
Pefect
OK
By the program,
[print "Pefect"] is carried out only when input 100.
[a=100] is dtescription
for judging 'a' equal '100', not substitution.
Other,
a<100 'a is
smaller than 100'
a>100 'a is bigger than 100'
a<=100 'a is 100 or
less'
a>=100 'a is 100 or more'
There are these judgments.
10 input a
20 if a<100 then print "small" else print
"big or ="
This program is,
when conditional expression is right then,
the statement following 'THEN' are carried out,
when it isn't so then, the
statement following 'ELSE' are carried out.
Execution example
run
?
300 (input any numerical value from keyboard here)
big or
=
OK
When judging on two or more conditions.
if a>50 and
a<100 then print "OK"
'and' is used judging when matching both of two
conditions.
if a<100 or a/5=0 then print "OK"
'or' is used judging
when matching any one of two conditions.
Multi statement.
To
describe the multiple statement in a single line.
10 input a
20 if
a=100 then locate 10,10:print "Pefect"
'locate' is the command to move a
cursor to the specified position.
Separating by colon":", plural commands
can be described with line up.
In this case, if the condition is true,
after moving the cursor to position(10,10), "Pefect" is
displayed.