編集

次の方法で共有


File.Pos() Method

Version: Available or changed with runtime version 1.0.

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

Note

This method is supported only in Business Central on-premises.

Syntax

Position :=   File.Pos()

Note

This method can be invoked using property access syntax.

Note

This method can be invoked without specifying the data type name.

Parameters

File
 Type: File
An instance of the File data type.

Return Value

Position
 Type: Integer

Remarks

This method is often used with Len Method (File) and Seek Method (File).

Example

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.

 var
    Testfile: File;
    Position: Integer;
begin
    File.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);  
end;

File Data Type
Get Started with AL
Developing Extensions