Text file I/O: Assign/Rewrite/Reset/WriteLn(f,…)/CloseFile missing
- Type: library / RTL (Track B)
- Status: done
- Owner: —
- Opened: 2026-06-20 (next
examples/adventureblocker after call-result - Closed: 2026-06-21 member access landed)
- Relation: the current
examples/adventureblocker (engine.pas:563). Not a compiler bug — a missing RTL surface.
Symptom
examples/adventure/engine.pas:563 (TGame.SaveTo):
var f: Text;
begin
Assign(f, path); Rewrite(f);
WriteLn(f, 'room=' + Player.RoomId);
…
pascal26:563: error: undefined variable (Assign)
The classic Pascal text-file API over a Text (file) handle is not provided:
Assign/AssignFile, Rewrite, Reset, Append, WriteLn(f, …) /
Write(f, …), ReadLn(f, …), Eof(f), Close/CloseFile. SaveTo/LoadFrom in
adventure need write + read.
Notes / direction
- The compiler already has raw sys-file builtins (
tkSysOpen/tkSysRead/tkSysWriteand the loadfile path) — aText-handle RTL unit can wrap those (open/creat + write/read + close) with a small buffered record type, FPC naming. Keep it our-own-RTL (see strategy memory), no real FPC RTL. WriteLn(f, …)/Write(f, …)need the file-handle first-argument form of the existing Write/WriteLn lowering (currently console-only). That part may need a small compiler touch (recognise a file-handle first arg) — confirm whether it can be pure-library via an overload or needs the writer to accept a handle. If a compiler hook is required, split a Track-A sub-ticket.
Acceptance
- A program that
Assign/Rewrite/WriteLn(f,…)/ClosethenReset/ReadLn(f,…)/Closeround-trips text through a file. examples/adventureSaveTo/LoadFrom compile; adventure gets pastengine.pas:563.
Log
- 2026-06-20 — Opened. Surfaced after
feature-member-access-on-call-resultunblockedengine.pas:446/462; the next adventure line (563,Assign(f, path)) needs text-file RTL. - 2026-06-20 — Added to
make library-suite-discoveryasdemo_adventure. Current pinned v18 output remainsundefined variable (Assign). This is the first consumer for the new PAL byte-handle layer: implement classic text-file RTL onPalOpen/PalRead/PalWrite/PalClose, splitting a Track A ticket only if the file-handleWriteLn(f, ...)surface needs compiler lowering. - 2026-06-20 — First Track B slice landed locally (commit f9bdeb8):
lib/rtl/textfile.pasdefinesText,Assign/AssignFile,Reset,Rewrite,Append,Close/CloseFile,Eof,IOResult, and explicitTextReadLn/TextWriteLnon the PAL byte-handle API.test/lib_textfile.pasround-trips lines through a POSIX PAL file and is wired into the library suite. Remaining adventure-compatible syntax is not pure library today: FPC-styleText/Assignneeds a default surface decision, andReadLn/WriteLnare lexer keywords. Track the compiler/default-surface follow-up infeature-textfile-keyword-io-dispatchbefore this ticket can close. - 2026-06-21 — Compiler support for
Assign/Reset/Rewritekeywords and Text file I/O dispatch has landed in the stable compiler (feature-textfile-keyword-io-dispatch). The adventure game and all text-file tests compile and run successfully using the new units.