Xbasic
IF ... THEN ... ELSE, ELSEIF
Syntax
IF Logical_Expression1 [ THEN ]
[ Statements1 ]
[ ELSEIF Logical_Expression2 [ THEN ]
[ Statements2 ]]
...
[ ELSEIF Logical_ExpressionN [ THEN ]
[ StatementsN ]]
[ ELSE
[ Statements ]]
END IF
Arguments
- Logical_Expression1
An expression that evaluates to .T. (TRUE) or .F. (FALSE).
- Logical_Expression2 ... Logical_ExpressionN
Optional. Expressions that evaluates to .T. (TRUE) or .F. (FALSE).
Description
Executes the statements for the first logical expression that evaluates to TRUE.
Discussion
IF ... THEN ... ELSE is a conditional control structure, executing the statements for the first logical expression that evaluates to TRUE. If no expression evaluates to TRUE, statements supplied after the else clause are executed. IMPORTANT: The then and else clauses must be the last words on the line. SELECT ... CASE, IIF(), CASE()
Associate a grade with a score. Any score below 60 is an F.
FUNCTION test_grade as C(score as N) if score >= 90 then grade = "A" elseif score >= 80 then grade = "B" elseif score >= 70 then grade = "C" elseif score >= 60 then grade = "D" else grade = "F" end if test_grade = grade end FUNCTION
ENDIF command
The ENDIF keyword can be used interchangeably with the END IF command.
See Also