The TRUNCATE_LUN procedure truncates the contents of a file (which must be open for write access) at the current position of the file pointer. After this operation, all data before the current file pointer remains intact, and all data following the file pointer are gone. The position of the current file pointer is not altered.
Truncate the entire contents of an existing file:
OPENU, unit, 'baddata.dat', /GET_LUN
Given an existing file of 10,000 bytes, throw away the final 5,000 bytes, and then write an additional 2,000 byte array in their place. The resulting file will be 7,000 bytes in length.
OPENU, unit, 'mydata.dat', /GET_LUN
POINT_LUN, unit, 5000
WRITEU, unit, BYTARR(2000)
TRUNCATE_LUN, Unit1, ..., Unitn
Scalar or array variables containing the logical file unit numbers of the open files to be truncated.
GET_LUN, OPENR/OPENU/OPENW, POINT_LUN