Files
gw-basic-2026/tests/programs/file_io.bas
T
Eremey Valetov c2d73e9c24 Phase 3: file I/O, PRINT USING, SAVE/LOAD, MID$ assignment, graphics stubs
Add OPEN/CLOSE with both modern (OPEN "f" FOR OUTPUT AS #n) and compact
(OPEN "O",#n,"f") syntaxes. PRINT#, WRITE#, INPUT#, LINE INPUT# for
sequential file access. EOF() now returns real file status with peek-ahead.
LOC/LOF return approximate values.

PRINT USING with numeric (#, ., +, -, $$, **, ^^^^, comma grouping) and
string (!, &, \ \) format specifiers. Shared by PRINT USING and PRINT# USING.

SAVE (ASCII), LOAD (with ,R auto-run), and MERGE for program persistence.

MID$ assignment (MID$(var$, start [,len]) = expr) for in-place string
modification. Works with both scalar variables and array elements.

Graphics stubs for SCREEN, PSET, PRESET, LINE, CIRCLE, DRAW, PAINT,
VIEW, WINDOW, PALETTE - parse and discard arguments so graphics-heavy
programs don't crash.

SYSTEM and NEW/CLEAR now close all open files. Version bumped to 0.3.0.
22 tests pass (16 existing + 6 new).
2026-02-10 11:53:28 -05:00

12 lines
280 B
QBasic

10 REM File I/O test
20 OPEN "/tmp/gwbasic_fio_test.txt" FOR OUTPUT AS #1
30 PRINT #1, "Hello from GW-BASIC"
40 PRINT #1, "Second line"
50 CLOSE #1
60 OPEN "/tmp/gwbasic_fio_test.txt" FOR INPUT AS #1
70 LINE INPUT #1, A$
80 LINE INPUT #1, B$
90 CLOSE #1
100 PRINT A$
110 PRINT B$