PBXB64 File I/O & System
File I/O & System Operations Standard
Complete file I/O and system operations API. Sequential and random-access files, file system manipulation, environment access, command-line parsing, and directory enumeration. All functions are real Win32 implementations, not stubs.
Sequential File I/O
OPEN / PRINT # / LINE INPUT
FUNCTION PBMAIN() AS LONG
LOCAL f AS LONG
LOCAL s AS STRING
OPEN "test.txt" FOR OUTPUT AS #1
PRINT #1, "Hello World"
PRINT #1, 42
CLOSE #1
OPEN "test.txt" FOR INPUT AS #1
LINE INPUT #1, s
PRINT "Read: "; s
CLOSE #1
FUNCTION = 0
END FUNCTIONOPEN supports FOR INPUT, OUTPUT, APPEND, and BINARY modes. PRINT #, LINE INPUT #, and GET/PUT for binary files. File numbers are validated at runtime.
File System Functions
KILL, NAME, DIR$, SHELL
FUNCTION PBMAIN() AS LONG
LOCAL f AS STRING
KILL "old_temp.txt" ' Delete file
NAME "old.txt" AS "new.txt" ' Rename file
f = DIR$("*.txt") ' First .txt file
WHILE LEN(f) > 0
PRINT f
f = DIR$ ' Next file
WEND
SHELL "notepad test.txt" ' Launch external program
FUNCTION = 0
END FUNCTIONKILL, NAME, DIR$ (with wildcard support), SHELL, and MKDIR/RMDIR/CHDIR are all real Win32 implementations. ENVIRON$ reads environment variables; COMMAND$ returns the command line.
Try it yourself
CLI - compile and run
PBXB64 test_file_io.pb -o test_file_io.exe
test_file_io.exe
PBXB64 test_dir.pb -o test_dir.exe
test_dir.exeAll test files are in examples/basic/ - compile and run to verify.