The IF clause is used to determine the flow to be executed depending on either the true or false (successful or unsuccessful) result of the statement. If the statement evaluates to a ‘true’ then the statements following the THEN clause will get executed. If the statement evaluates to a ‘false’ then the set of statements following the ‘ELSE’ clause would get executed. In most cases, either the THEN or the ELSE must be specified; optionally both may be. In certain specific cases the ELSE clause only is available.
For each of these statements the format of the THEN and ELSE clauses is the same. If the THEN or ELSE clause is restricted to one statement, on the same line as the test statement, the THEN or ELSE can be specified in the simple format.
If the THEN or ELSE clause contains more than one statement, or you wish to place it on a separate line, you must use the multiline format that encloses the statements and terminates them with an END.
Example
IF AGE <= 17 THEN PRINT "AGE IS LESSER THAN OR EQUAL TO 17" PRINT "MINOR" END ELSE PRINT "MAJOR" END
0 comments:
Post a Comment