Editing Programs¶
The Curses UI provides a full-screen text editor for writing BASIC programs.
Editor Layout¶
┌─ MBASIC Editor ─────────────────────────┐
│ 10 PRINT "Hello, World!" │
│ 20 END │
│ _ │
│ │
│ │
│ │
│ │
│ │
│ │
└─ [{{kbd:run:curses}}: Run] [{{kbd:parse:curses}}: Help] ─────────┘
Entering Programs¶
- Type line numbers followed by BASIC statements
- Press Enter to add each line
- Lines are automatically sorted by number
Example:
Line Numbers¶
- Required - Every program line needs a number
- Range - 0 to 65529
- Convention - Use multiples of 10 (10, 20, 30...)
- Sorting - Lines are automatically sorted by number
Editing Existing Lines¶
To change a line, just retype it with the same number:
Change to:
The new version replaces the old one.
Deleting Lines¶
Type just the line number and press Enter:
Or use the DELETE command:
Inserting Lines¶
Use line numbers between existing lines:
Insert line 20:
Result:
Navigation¶
| Key | Action |
|---|---|
| Arrow Keys | Move cursor |
| Home/End | Start/end of line |
| Page Up/Down | Scroll editor |
Keyboard Shortcuts¶
See your UI's keyboard shortcuts documentation for the complete list.
Common shortcuts:
- {{kbd:run:curses}} - Run program
- {{kbdcurses}} - New program (clear)
- {{kbd:save:curses}} - Save program
- {{kbd:open:curses}} - Load program
- {{kbd:parse:curses}} - Help
Renumbering Lines¶
Use RENUM to renumber your program:
RENUM (renumber starting from 10, step 10)
RENUM 100 (start from 100)
RENUM 100,20 (start from 100, step 20)
See: RENUM Command
Auto-Numbering¶
Type AUTO to start automatic line numbering:
AUTO
10 PRINT "Line 1" (number added automatically)
20 PRINT "Line 2" (number added automatically)
30 PRINT "Line 3" (number added automatically)
Exit AUTO mode with {{kbd:continue:curses}} or by typing a line number manually.
See: AUTO Command
Line Editing with EDIT¶
The EDIT command is supported for compatibility with traditional BASIC, but the Curses UI provides full-screen editing capabilities that make it unnecessary. You can directly navigate to any line and edit it in the full-screen editor.
See: EDIT Command for traditional usage
Direct Mode¶
Lines without numbers execute immediately:
This is useful for testing expressions.
Multiple Statements Per Line¶
Use colon (:) to separate statements:
Comments¶
Use REM or apostrophe for comments:
Tips¶
- Use 10 increments - Leaves room to insert lines
- RENUM periodically - Keep numbers clean
- Save often - Don't lose your work
- Use comments - Document your code
- Test as you go - Run small sections first
Common Mistakes¶
Forgetting line numbers:
Line numbers out of order:
The editor automatically sorts them as 10, 30.Typos in line numbers:
This is a syntax error! The parser will reject "1O" as an invalid line number.