Siebel VB Language Reference > Methods Reference for Siebel VB > File Input and Output Methods >

Get File Position Method


The Get File Position method returns the current position of an open file depending on the following mode that it uses to open the file:

  • Random mode. It returns the number of the next record to be read or written.
  • Other modes It returns the file offset of the next operation.

The first byte in the file is at offset 1, the second byte is at offset 2, and so on. The return value is a long number.

Format

Seek(filenumber)

The following table describes the arguments that you can use with this method.

Argument
Description

filenumber

The file number that the Open statement uses to open the file. For more information, see Open File Method.

Example

The following example reads the contents of a sequential file line by line to a carriage return, and then displays the results. The CreateFile subroutine creates the c:\temp001 file that the main subroutine uses:

(general) (declarations)
Option Explicit
Declare Sub CreateFile

Sub CreateFile
   Rem Put the numbers 10-100 into a file
   Dim x as Integer
   Open "c:\temp001" for Output as #1
   For x = 10 to 100 step 10
      Write #1, x
   Next x
   Close #1
End Sub

Sub Button_Click
   Dim testscore as String
   Dim x
   Dim y
   Dim newline
   Call CreateFile
   Open "c:\temp001" for Input as #1
   x = 1
   newline = Chr(10)
   msgtext = "The test scores are: " & newline
   Do Until x = Lof(1)
      Line Input #1, testscore
      x = x + 1
      y = Seek(1)
      If y>Lof(1) then
         x = Lof(1)
      Else
         Seek 1,y
      End If
      msgtext = msgtext & newline & testscore
   Loop
   Close #1
      Kill "c:\temp001"
End Sub

Siebel VB Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.