Source Files, Continuations, and Comments

LunarBasic combines continued physical lines into logical source lines before parsing. Blank lines and comments are ignored so the parser can focus on real code.

Back to Language Reference


How Source Files Are Read

Whitespace

This means you can space code out for readability without changing how it is parsed.

Line Continuation

Place a standalone underscore at the end of a physical line to continue the statement on the next line. At least one whitespace character must appear immediately before the underscore.

total = firstValue + _
    secondValue + _
    thirdValue

DrawText font, _
    x, y, _
    "Hello"
Function AddValues( _
    left As Integer, _
    right As Integer _
) As Integer
    Return ( _
        left + right _
    )
End Function

Apostrophe Comments

An apostrophe starts either a full-line comment or an inline comment.

' full line comment counter = counter + 1 ' inline comment

Anything after the apostrophe on the same line is ignored.

Block Comments

Block comments start with Rem and end with End Rem.

Rem this text is ignored End Rem