Program Shape and Statements

A LunarBasic program is a sequence of top-level statements. Think of it as a list of actions and declarations the parser reads from top to bottom.

Back to Language Reference


Top-Level Statement Types

Enum Declarations

Named constants can be declared at the top level with Enum and End Enum. Use members with EnumName.MemberName.

Enum Direction
    North
    South
End Enum

Dim dir As Direction
dir = Direction.North

See Enums for member value rules and common enum diagnostics.

Type Declarations

User-defined data types are declared at the top level with Type and End Type. Fields are declared inside the block with Field.

Type Player
    Field Name As String
    Field Score As Integer
End Type

See Types and Objects for the full reference, including New and field access.

Expression Statements

A routine call or a system-function call can stand on its own as a statement.

System functions also support the bare-call form without parentheses.

Graphics 800, 600 LoadFont "Fonts/ui.ttf", 24 DrawText uiFont, 32, 32, "Hello" Cls Flip