Loc Function

Purpose

Returns the current position of the file data pointer.

Syntax

large = Loc(#n)

% = Loc%(#n)

Description

Loc[%](#n) works only on files previously opened with Open using channel n ( 0 <= n <= 511) and returns the current position of the data pointer (locate).

Loc() returns a 64-bit integer and is suited for files sizes of 4 GB.

Loc%() returns a 32-bit integer and is suited for files sizes with a maximum of 2 GB.

Example

Local a$, n As Int32

OpenW # 1

Open "c:\TEST.DAT" for Output As # 1

For n = 1 To 7

Write # 1, Format(n, "dddd")

Next n

Close # 1

Open "C:\TEST.DAT" for Input As # 1

Do Until EOF(# 1)

Input # 1, a$

Print " "; a$, Loc(# 1)

Loop

Close # 1

Kill "c:\test.dat" // Tidy-up Line

Opens the file TEST.DAT in current directory andreads its contents as well as the position of the data pointer until end of file.

Remarks

The functions Loc%(), Lof%(), Record%#, Seek%#, RelSeek%# etc. always use 32 bits integers and are therefore limited to files with a maximum size of 2 GB

See Also

Eof(), Lof(), Record#, Seek#, RelSeek#

{Created by Sjouke Hamstra; Last updated: 12/10/2014 by James Gaite}