File & Directory Commands (V26)

FILECOPY

Syntax: FILECOPY source$, dest$

Copies a file from source to destination. Returns nonzero on success.

IF FILECOPY("src.txt", "dst.txt") THEN PRINT "OK"

RMDIR

Syntax: RMDIR path$

Removes an empty directory.

RMDIR "C:\\Temp\\MyFolder"

GETATTR

Syntax: GETATTR(path$)

Returns file/directory attributes as a bitmask.

LOCAL attr AS LONG
attr = GETATTR("myfile.txt")
IF attr AND 1 THEN PRINT "Read-only"

SETATTR

Syntax: SETATTR path$, attrs

Sets file/directory attributes.

SETATTR "myfile.txt", &H01    ' Set read-only

RESET

Syntax: RESET

Closes all open files.

OPEN "data.txt" FOR OUTPUT AS #1
OPEN "log.txt" FOR OUTPUT AS #2
RESET     ' Closes both #1 and #2

FLUSH

Syntax: FLUSH #n

Flushes the file buffer for the given file handle, ensuring all buffered data is written to disk.

PRINT #1, "Important data"
FLUSH #1    ' Force write to disk

SETEOF

Syntax: SETEOF #n

Sets the end-of-file marker at the current file position. Truncates the file beyond this point.

SEEK #1, 100
SETEOF #1    ' Truncate file at position 100

REMAIN$

Syntax: REMAIN$(#n)

Returns the number of remaining characters in an open file after the last GET operation.

LOCAL remaining AS STRING
remaining = REMAIN$(1)
PRINT remaining; " bytes left"