SecondBASIC Documentation v3

Home / Command Reference / If...End If

If...End If

Description: Executes code based on if a set of criteria is met or not.

Syntax:

If <Expression> Then
    ' Code
[Else, Elseif <Expression>> Then]
    ' Code
End If

Part Description
<Expression> Required. The <Expression> must return true or false.

Example:

    a = 5
    b = a
 
    If a < 5 Then
        Print "a is less than 5"
    ElseIf a > 5 Then
        Print "a is greater than 5"
    Else
        Print "a is 5"
        If b = 5 Then Print "b is also 5"
    End If