file% = FNopentempfile IF file% = 0 ERROR 100, "Failed to open temp file" PRINT #file%, "Hello world!" PTR#file% = 0 INPUT #file%, message$ CLOSE #file% PRINT message$ END DEF FNopentempfile LOCAL pname%, hfile%, chan% OPEN_EXISTING = 3 FILE_FLAG_DELETE_ON_CLOSE = &4000000 GENERIC_READ = &80000000 GENERIC_WRITE = &40000000 INVALID_HANDLE_VALUE = -1 DIM pname% LOCAL 260 FOR chan% = 5 TO 12 IF @hfile%(chan%) = 0 EXIT FOR NEXT IF chan% > 12 THEN = 0 SYS "GetTempFileName", @tmp$, "BBC", 0, pname% SYS "CreateFile", $$pname%, GENERIC_READ OR GENERIC_WRITE, 0, 0, \ \ OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0 TO hfile% IF hfile% = INVALID_HANDLE_VALUE THEN = 0 @hfile%(chan%) = hfile% = chan%