Constants are either numeric values, string values, or in some cases compiler functions, which are evaluated and fixed at compile time rather than at run time.
String Constants
These are enclosed in double quotes, e.g.
NAME$ = "Smiley O'Reilly"
To include a double quote character (ASCII value 34) within a constant string, use two of them together, e.g.
TOOL$ = "6"" Wrench" ! evaluates/displays as 6" Wrench
There is no syntax for embedding control characters or escape sequences directly within literal constant strings. Instead, such strings must be built using a combination of concatenation and the CHR(x) function, e.g.
ONE'TWO$ = "Buckle" + chr(13) + chr(10) + "my shoe." ! (CRLF embedded in middle of string)
Numeric Constants
These come in the following flavors:
• Decimal values (integer or floating point), with optional leading minus sign. Note that the decimal point character is the (American-style) period; commas are not allowed, nor is scientific/exponential notation. Examples:
A = 25 ! Good: decimal integer
B = -2.3 ! Good: negative decimal floating point
C = 2.3- ! Illegal: trailing unary minus sign not allowed
D = 12345.67 ! Good: positive decimal floating point
E = 12,345.67 ! Illegal: commas not allowed
• Hexadecimal and octal values are denoted with a leading "&h" or "&o" (case sensitive), respectively; e.g.
F = &h100 ! Good: hex 100 (256 decimal)
G = &o100 ! Good: octal 100 (64 decimal)
H = &H100 ! Bad: &H not recognized (must be lower case)
I = &O100 ! Bad: &O not recognized (must be lower case)
• Single-byte ASCII values are denoted by enclosing the ASCII character in single-quotes, e.g.
A = 'A' ! Good: ASCII A (65 decimal); same as A = 65
Note that the hex and octal notation described above is also recognized by the various forms of INPUT statements, DATA, and GDI print directives. The ASCII byte notation, however, is not.
Symbols
These are created with the DEFINE statement are treated by the compiler equivalently to literal string or numeric constants, depending on whether the symbol name ends in a dollar sign, e.g.
DEFINE FREEDOM_FRIES$ = "French Fries" ! define string constant
DEFINE FF_COUNT = 25 ! define numeric constant
? FF_COUNT;FREEDOM_FRIES$;" per serving" ! this statement compiles to same RUN code
? 25;"French Fries";" per serving" ! RUN code as this statement
Compiler Functions
These are functions that are evaluated by the compiler at compile-time rather than by the interpreter at run-time, and thus are equivalent to constants. See the "Related Topics" below.