The GetFilePos function reads the current file pointer position of an open file channel.
FACTS:
* none
Mini Tutorial:
This example creates a 256 byte file, it then uses the FilePos command to skip into the created file and read bytes 100 to 110. Then finally displaying the FilePos after the read.
; Create a temp file name File$=TempDir$()+"PB_TestFile.txt" ; Create a File for writing data to WriteFile File$,1 ; Make a file of 255 bytes values For lp=0 To 255 WriteByte 1,lp Next ; Close this file channel CloseFile 1 Print "============================" Print "Reading File:"+File$ Print "============================" ; Get the Size of this file in bytes Size=FileSize(File$) ; Open a file to READ with READFILE ReadFile File$,1 ; Set the current File Pointer Position in ; File channel 1 To start at byte 100 into ; this file FilePos 1,100 ; Read 10 bytes from this position For lp=1 To 10 ; Read and display this byte Print " Byte Data:"+Str$(ReadByte(1)) Next ; Display the Current File Pointer Position Print "File Pointer Position:"+Str$(GetFilePos(1)) ; Close this file channel CloseFile 1 If FileExist(file$) Then DeleteFile file$ ; Display the screen and wait for a key press Sync WaitKey |
This example would output.
============================ Reading File: C:\Windows\Temp\Pb_TestFile.txt ============================ Byte Data:100 Byte Data:101 Byte Data:102 Byte Data:103 Byte Data:104 Byte Data:105 Byte Data:106 Byte Data:107 Byte Data:108 Byte Data:109 File Pointer Position:110 |
|