PBXB64 Datei-I/O & System

Datei-I/O & System Operations Standard

Vollständige Datei-I/O- und Systemoperations-API. Sequentielle und wahlfreie Dateien, Dateisystem-Manipulation, Umgebungszugriff, Kommandozeilen-Parsing, and Verzeichnis-Aufzählung. Alle Funktionen sind echte Win32-Implementierungen, not stubs.

Sequentielle Datei-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 FUNCTION

OPEN supports FOR INPUT, OUTPUT, APPEND, and BINARY modes. PRINT #, LINE INPUT #, and GET/PUT for binary files. File numbers are validated at runtime.

Dateisystem-Funktionen

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 FUNCTION

KILL, NAME, DIR$ (with wildcard support), SHELL, and MKDIR/RMDIR/CHDIR are all real Win32 implementations. ENVIRON$ reads environment variables; COMMAND$ returns the command line.

Probieren Sie es selbst

CLI - kompilieren und ausführen
PBXB64 test_file_io.pb -o test_file_io.exe test_file_io.exe PBXB64 test_dir.pb -o test_dir.exe test_dir.exe

Alle Testdateien befinden sich in examples/basic/ - kompilieren und ausführen zum Verifizieren.

Zurück zur Feature-Liste