IF string reference <> string expr THEN statement
IF string reference = string expr THEN statement
IF expr (relational operator) expr THEN statement
Supported by: COMX BASIC V1.00, Floating Point BASIC 2.2, Pecom 32 BASIC, Pecom 64 BASIC 1.0 and 4.0, Quest Super BASIC 5.0 and 6.0, RCA BASIC3 V1.1, Telmac SBASIC v 24.3
Quest Super BASIC 1.4 and 3.0: IF THEN
This statement is a conditional statement but it is not only a conditional branch. It tests for a condition, and if the condition is met, a statement or group of statements (separated by colons) is executed. If the condition is not met, then execution continues at the next line number. When string relations are compared, an equal or not equal sign is the only acceptable relation. In the case of arithmetic expressions, the following are acceptable relational operators:
<>not equal to
>=greater than or equal to
<=less than or equal to
The mode of the first expression defines the mode of the second expression. An example of a conditional statement follows.
In this case, if the value of A is equal to the value of B, then the value of A will be printed, a delay will occur and execution will continue at line #200. If A is not equal to B, then the value of B is printed and execution continues from line #20 onward.
One additional point to be made is that the keyword THEN is optional and need not be used. A common mistake to be avoided is the following.
IF A>N THEN 200
Anything to the right of THEN, if it appears, is to be an executable statement. The number 200 is not an executable statement. The correct version would be as follows.
IF A>B THEN GOTO 200
IF A>B GOTO 200
Some more examples of acceptable IF statements are given below. Note the multiple conditions in the last example. If any of the conditions are not met, execution continues at the next line number. If all of the conditions are met, execution will finally get transferred to line #500 by means of the GOTO statement. It follows that the GOTO statement could have been any executable statement.