TRUNCATE_LUN

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.

Examples

Example 1

Truncate the entire contents of an existing file:

OPENU, unit, 'baddata.dat', /GET_LUN

TRUNCATE_LUN, unit

FREE_LUN, unit

Example 2

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

TRUNCATE_LUN, unit

WRITEU, unit, BYTARR(2000)

FREE_LUN, unit

Syntax

TRUNCATE_LUN, Unit1, ..., Unitn

Arguments

Unitn

Scalar or array variables containing the logical file unit numbers of the open files to be truncated.

Keywords

None.

Version History

5.6

Introduced

See Also

GET_LUN, OPENR/OPENU/OPENW, POINT_LUN