Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?

IF (statement)

Description

Allows for the conditional execution of some statements. It takes the general form:

IF expression THEN|ELSE statement

Where:

  • The expression evaluates to a value of Boolean TRUE or FALSE.
  • If the expression is TRUE, the statements defined by the THEN clause will execute (if present).
  • If the expression is FALSE, the statements defined by the ELSE clause, if any will execute.
  • The THEN and ELSE clauses may take two different forms being single and multiple line statements.

The simplest form of either clause is of the form:

IF A THEN CRT A

or

IF A ELSE CRT A

However, the END keyword may be used to expand the clauses to enclose multiple lines of code as so:

     IF A THEN
         A = A*6
         CRT A
     END ELSE
         A = 76
         CRT A
     END

It is possible to combine the single and multi-line versions of either clause to make complex combinations of the command. For reasons of readability it is suggested that where both clauses are present for an IF statement that the same form of each clause is coded.

IF statements can be nested within either clause to any number of levels.

An example of use is as:

0001     CRT "Are you sure (Y/N) ":
0002     INPUT Answer,1
0003     IF OCONV (Answer, "MCU")= "Y" THEN
0004     *Call delete subroutine here
0005         CRT "Files have been deleted"
0006     END ELSE
0007         CRT "File delete was ignored"
0008     END


Go back to jBASE BASIC.

Was this article helpful?