The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.
TRUNC Method (File)
Truncate an ASCII or binary file to the current position of the file pointer.
Use this variable to refer to the file.
Typically, you use this method together with SEEK Method (File). Use File.SEEK to position the pointer in the file and then use File.TRUNC to truncate the file at that point.
The following example sets a pointer at position 20 in a file and truncates the file at the pointer position. The WRITEMODE Method (File) allows the file that is named C:\TestFolder\TestFile.txt to open in write mode. The SEEK method sets a pointer at position 20 in the file and then the TRUNC Method (FILE) truncates the contents at the pointer position. This example assumes that you have created a text file named C:\TestFolder\TestFile.txt. The file is then saved a truncated file. This example requires that you create the following global variable.
TestFile.WRITEMODE(TRUE); TestFile.OPEN('C:\TestFolder\TestFile.txt'); TestFile.SEEK(20); TestFile.TRUNC;