The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.

POS Method (File)

Gets the current position of the file pointer in an ASCII or binary file.


Position := File.POS  


Type: file

Use this variable to refer to the file.

Property Value/Return Value

Type: Integer

This show the current position of the file pointer in bytes.


This method is often used with LEN Method (File) and SEEK Method (File).


The following example opens a text file that is named C:\TestFolder\TestFile.txt. The WRITEMODE Method (File) enables the file to be open in write mode. The POS method 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 Method (File) method sets a file pointer at position 5. After the SEEK Method (File) is executed, the POS method 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 global variables.

Variable name DataType
TestFile File
Position Integer

Position := TestFile.POS;  
MESSAGE('Pointer position before SEEK: %1', Position);  
Position := Testfile.POS;  
MESSAGE('Pointer position after SEEK: %1', Position);  

See Also

File Data Type