Blitz3D+ Command Reference

Else

Parameters

None.

Description

Starts the block that runs when an If condition is false.

Else sits between the If body and its EndIf, and gives you the "otherwise" branch:

If ammo > 0
    Fire()
Else
    PlaySound click
EndIf

There can be only one Else per If, and it must come last - after any ElseIf branches. It has no condition of its own; it simply catches everything the branches above did not.

Else needs the block form of If. There is no single-line "If ... Then ... Else ..." in Blitz3D+, so as soon as you need an else branch, open a proper block.

Its Select equivalent is Default, which catches whatever no Case matched.

See also: If, ElseIf, EndIf, Then, Default.

Example

; Else Example
; ------------

; The pilot's status after the last battle
hull=30

If hull>=40 Then
    Print "Hull at "+hull+"% - fly carefully out there."
Else
    ; The Else block runs only when the condition above is NOT met
    Print "Hull at "+hull+"% - return to base immediately!"
End If

Print ""
Print "Press any key to close the example"
WaitKey

End

Index