RosettaCodeData/Task/Truncate-a-file/PowerBASIC/truncate-a-file.powerbasic
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

17 lines
406 B
Text

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