SEEK Function (File)
Sets a file pointer to a new position in an ASCII or binary file.
File.SEEK(Position)
Parameters
- File
Type: File The file in which to set the pointer.
- Position
Type: Integer The position at which to set the pointer.
Remarks
This function is often used with POS Function (File) and LEN Function (File).
Example
The following example sets a pointer at position 20 in a file and truncates the file at the pointer position. The WRITEMODE Function (File) enables a file named C:\TestFolder\TestFile.txt to open in write mode. The SEEK function sets a pointer at position 20 in the file and then the TRUNC Function (File) truncates the contents of the file at the pointer position. This example assumes that you have created the text file C:\TestFolder\TestFile.txt.This example requires that you create the following variable in the C/AL Globals window.
Variable name | DataType |
---|---|
TestFile |
File |
TestFile.WRITEMODE(TRUE);
TestFile.OPEN('C:\TestFolder\TestFile.txt');
TestFile.SEEK(20);
TestFile.TRUNC;