Character Set¶
BASIC-80 uses the ASCII character set.
Valid Characters¶
BASIC-80 programs can use:
Letters: A-Z (uppercase and lowercase) Digits: 0-9 Special symbols: See below
Special Characters in BASIC¶
| Character | Name | Usage |
|---|---|---|
| " | Quote | String delimiters: "Hello" |
| ' | Apostrophe | Comment: 10 ' Comment |
| : | Colon | Statement separator: A=5:B=10 |
| ; | Semicolon | Print separator, statement continuation |
| , | Comma | List separator, print tab |
| . | Period | Decimal point: 3.14 |
| + | Plus | Addition, positive sign |
| - | Minus | Subtraction, negative sign |
| * | Asterisk | Multiplication |
| / | Slash | Division |
| \ | Backslash | Integer division |
| ^ | Caret | Exponentiation: 2^3 |
| = | Equals | Assignment, comparison |
| < | Less than | Comparison |
| > | Greater than | Comparison |
| ( | Left paren | Grouping, function calls |
| ) | Right paren | Grouping, function calls |
| $ | Dollar | String type suffix: NAME$ |
| % | Percent | Integer type suffix: COUNT% |
| ! | Exclamation | Single precision suffix: X! |
| # | Hash | Double precision suffix: PI#, file number |
| & | Ampersand | Hexadecimal/octal prefix: &HFF, &O77 |
| _ | Underscore | Allowed in variable names (some versions) |
String Characters¶
Strings can contain any printable ASCII characters (32-126):
Control Characters¶
BASIC supports some control characters:
| Code | Character | Usage |
|---|---|---|
| 7 | BEL | Bell/beep: PRINT CHR$(7) |
| 8 | BS | Backspace |
| 9 | TAB | Tab character |
| 10 | LF | Line feed (new line) |
| 13 | CR | Carriage return (return to line start) |
| 27 | ESC | Escape character |
Use CHR$() to include control characters in strings.
Reserved Words¶
Cannot be used as variable names:
- All BASIC statements (PRINT, FOR, IF, etc.)
- All functions (SIN, COS, LEFT$, etc.)
- Reserved keywords (AND, OR, NOT, TO, STEP, etc.)
See: Statements, Functions
Variable Names¶
Valid variable names: - Start with a letter (A-Z) - Can contain letters and digits - Can end with type suffix ($, %, !, #) - Maximum length varies by implementation
Valid:
Invalid:
2X ' Cannot start with digit
A+B ' Cannot contain operators
FOR ' Reserved word
PRINT$ ' Reserved word
Case Sensitivity¶
BASIC-80 is not case sensitive:
Convention: Use UPPERCASE for keywords, mixed case for variables.
Line Terminators¶
Programs can use different line endings:
- CR+LF (Windows: \r\n)
- LF (Unix/Linux: \n)
- CR (Old Mac: \r)
MBASIC accepts all formats.
Comments¶
Two ways to add comments:
Everything after REM or ' is ignored.
String Escaping¶
BASIC does not have escape sequences like \n or \t.
Use CHR$() instead:
Hexadecimal and Octal¶
Use &H for hexadecimal, &O for octal:
Whitespace¶
- Spaces - Usually ignored, but required between keywords
- Tabs - Treated as spaces
- Blank lines - Allowed in programs
Special Sequences¶
Line continuation:
Not supported in MBASIC 5.21. Use : to combine statements:
String concatenation:
See Also¶
- ASCII Codes - Complete ASCII table
- Data Types - Variable types
- Operators - Operator symbols
- String Functions - CHR$, ASC, etc.