Programming question: File I/O from BASIC on the X16 emulator

grommile

New Member
Nov 24, 2019
3
3
3
Northampton, UK
I'm writing a game in BASIC on the X16, and I thought to myself "having load/save functionality is not essential but would be kind of neat".

Unfortunately, the command flow for creating and writing to a sequential file on the C1541:

1 DV=1:REM LOCAL FILESYSTEM ACCESS
10 OPEN 15,DV,15
20 OPEN 2,DV,2,"0:TESTFILE,S,W"
30 INPUT#2,E,M$,T,S:IF E<2 GOTO 70
40 PRINT#2, "TESTSTRING"
50 INPUT#15,E,M$,T,S:IF E<2 GOTO 70
60 PRINT "ERROR";E;M$;T;S:GOTO 80
70 PRINT "WRITTEN SUCCESSFULLY"
80 CLOSE 2:CLOSE 15

isn't working for me for local-filesystem access (OPEN 15,1,15 fails with ?ILLEGAL DEVICE NUMBER ERROR and trying to do a CLOSE 15 afterwards seems to upset the BASIC interpreter since it results in a cleared screen and the READY. prompt), and the X16 emulator (unlike, say, VICE x64) doesn't include an emulated 1541 (etc.) drive on device 8.

Can anyone offer guidance on what to do here? ("Wait for later revisions of the emulator and ROM" is a perfectly acceptable answer :) )