Siebel VB Language Reference > Siebel VB Language Reference >

Loc Function


This standard VB function returns the current offset within an open file.

Syntax

Loc(filenumber)

Argument
Description
filenumber
The number given in the Open statement, of the open file to query

Returns

For random files, the number of the last record read or written; for files opened in append, input, or output mode, the current byte offset divided by 128; for files opened in binary mode, the offset of the last byte read or written.

Example

This example creates a file of account numbers as entered by the user. When the user finishes, the example displays the offset in the file of the last entry made.

Sub Button_Click
   Dim filepos as Integer
   Dim acctno() as Integer
   Dim x as Integer
   x = 0
   Open "c:\TEMP001" for Random as #1
   Do
      x = x + 1
      Redim Preserve acctno(x)
      acctno(x) = 234
      If acctno(x) = 0 then
         Exit Do
      End If
      Put #1,, acctno(x)
   Loop
   filepos = Loc(1)
   Close #1
      Kill "C:\TEMP001"
End Sub

See Also

Eof Function
Lof Function
Open Statement


 Siebel VB Language Reference
 Published: 18 June 2003