Below is a list of comparison symbols that may be used in the IF
statement and their meanings:
SYMBOL MEANING
EQUALS
> GREATER THAN
< LESS THAN
< > NOT EQUAL TO
> = GREATER THAN OR EQUAL TO
< = LESS THAN OR EQUAL TO
You should be aware that these comparisions work in expected
mathematical ways with numbers. There are different ways to
determine if one string is greater than, less than, or equal to
another. You can learn about these “string handling” functions by
referring to Chapter V, BASIC 7.0 Encyclopaedia.
Section 5 describes some powerful extensions of the IF-THEN
concept, consisting of BASIC 7.0 commands like BEGIN, BEND,
and ELSE.
Using the Colon
A very useful tool in programming is the colon (:). You can use
the colon to separate two (or more) BASIC commands on the
same line.
Statements after a colon on a line will be executed in order, from
left to right, ln one program line you can put as many statements
as you can fit onto 160 characters, including the line number.
This is equivalent to four full screen lines in 40-column format,
and two full lines in 80-column format. This provides an excellent
opportunity to take advantage of the THEN part of the IF-THEN
statement. You can tell the computer to execute several
commands when your IF condition is true. Clear the computer’s
memory and type in the following program:
10 N=1
20 IF N<5 THEN PRINT N;“LESS THAN 5”:GOTO 40
30 ? N; “GREATER THAN OR EQUAL TO 5”
40 END
4-4