RosettaCodeData/Task/Truncate-a-file/PowerBASIC/truncate-a-file.powerbasic

18 lines
406 B
Text
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
SUB truncateFile (file AS STRING, length AS DWORD)
IF LEN(DIR$(file)) THEN
DIM f AS LONG
f = FREEFILE
OPEN file FOR BINARY AS f
IF length > LOF(f) THEN
CLOSE f
ERROR 62 'Input past end
ELSE
SEEK f, length + 1
SETEOF f
CLOSE f
END IF
ELSE
ERROR 53 'File not found
END IF
END SUB