POS Function (File)
Gets the current position of the file pointer in an ASCII or binary file.
Position := File.POS
Use this variable to refer to the file.
Property Value/Return Value
This show the current position of the file pointer in bytes.
The following example opens a text file that is named C:\TestFolder\TestFile.txt. The WRITEMODE Function (File) enables the file to be open in write mode. The POS function retrieves the position of the file pointer and stores it in the Position variable. When the file is open, the position of the pointer is 0 because a pointer is not set. The SEEK Function (File) function sets a file pointer at position 5. After the SEEK Function (File) is executed, the POS function returns 5 as the file pointer position. This example assumes that you have created a text file named C:\TestFolder\TestFile.txt. This example requires that you create the following variables in the C/AL Globals window.
TestFile.WRITEMODE(TRUE); TestFile.OPEN('C:\TestFolder\TestFile.txt'); Position := TestFile.POS; MESSAGE('Pointer position before SEEK: %1', Position); Testfile.SEEK(5); Position := Testfile.POS; MESSAGE('Pointer position after SEEK: %1', Position);