# filetruncate

Changes the size of a file. (version 4.67 or later)

    filetruncate <filename> <size>

## Remarks

Changes the <size> bytes of a <filename> file.
Null characters('\0') are appended if the file is extended.

The system variable "result" value is set to 0 if the file size is successfully changed. The system variable "result" value of -1 indicates an error.

## Example

    ; Changes 32 bytes of a file.
    filetruncate 'test.exe' 32
    if result = -1 then
    	messagebox 'file truncate error' 'filetruncate'
    else
    	messagebox 'file truncate success' 'filetruncate'
    endif

    ; Makes 8M bytes of a file containing all zero data.
    size = 8*1024*1024
    filetruncate 'bigfile.bin' size

    ; Opens a log file at the macro file directory.
    getdir dir
    sprintf2 filename '%s\test.log' dir
    logopen filename 0 0
    ; Limitation of a file size
    maxsize = 512
    counter = 0

    :loop
    counter = counter + 1
    sprintf2 line 'counter = %d' counter
    logwrite line
    logwrite #13#10
    filetruncate filename maxsize
    if result = -1 then
    	messagebox 'file truncate error' 'filetruncate'
    	goto skip
    endif
    if counter > 32 goto skip
    goto loop

    :skip
    logclose