Names and Values
This page explains the basic building blocks you write inside LunarBasic code: names, numbers, strings, booleans, and coordinates.
Identifiers
Identifiers are the names you give variables, constants, labels, and routines.
- An identifier must start with a letter or _.
- After that it may contain letters, digits, _, $, %, #, or !.
counter
_temp
name$
value1
Classic Type Suffixes
LunarBasic supports classic BASIC-style type suffixes on identifier names. These suffixes automatically affect the identifier's data type.
- $ means String
- % means Integer
- ! means Float
- # means Double
Examples:
playerName$
score%
speed!
distance#
If an identifier has one of these suffixes, that suffix type is used by the compiler. This applies to variables, constants, parameters, loop variables, and function names.
You can still use As syntax, but if both are present they must agree. For example, name$ As String is valid, but name$ As Integer is not.
Number Literals
LunarBasic currently supports three number styles.
- Integer literals, parsed as 64-bit integers
- Floating-point literals, parsed as double-precision values
- Hexadecimal integer literals, written with an
&Hprefix
123
45.6
.5
&HFF
&h10
Hexadecimal literals use digits 0 through 9 and letters A through F after the &H prefix. The prefix is case-insensitive.
String Literals
Strings are wrapped in double quotes.
Doubled double-quotes are used to place a quote inside the string.
"hello"
"a""b"
"a""b" means a"b.
An unterminated string is a syntax error.
Boolean Literals
True
False
These are values, not keywords.
Case Sensitivity
- Keywords are recognized case-insensitively.
- Boolean literals are recognized case-insensitively.
- System functions are recognized case-insensitively.
- Next i matches the For loop variable name case-insensitively.
Coordinate System
The game-facing coordinate system is intended to be integer-based.
- Use integers for screen positions and sizes when possible.
- This keeps drawing and runtime behavior predictable.