Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

Loc

  • Last UpdatedJul 18, 2023
  • 1 minute read

Loc function returns a number indicating the current position within a file opened using the Open statement.

The required FileNum argument must contain an Integer representing any valid number associated with an open file.

Syntax

Loc(FileNum)

FileNum:

An Integer or numeric expression representing any valid number in the range 1 to 511 inclusive, which is referenced by the file system to be associated with an open file.

Return Value

Returns a Long representing the current position within a file, the value dependant upon which file access mode the file was opened with:

  • If the file was opened in Random mode, the Loc function will return a number representing the last record read from or written to the file.

  • If the file was opened in Sequential mode, the Loc function will return a number representing the current byte position in the file divided by 128. (However, information returned by Loc for Sequential files is neither used nor required.)

  • If the file was opened in Binary mode, the Loc function will return a number representing the position of the last byte read from or written to the file.

EOF | FileLen | LOF | Seek

Example

Dim lonLoc As Long

Dim strLine As String

Open "TESTFILE.txt" For Binary As #1 ' Open file

Do While lonLoc < LOF(1) ' Loop until end of file

strLine = strLine & Input(1, #1) ' Read character into variable

lonLoc = Loc(1) ' Get current position within file

Loop

<statements> ' Do stuff with retrieved data

Close #1 ' Close file

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in