BB___SEEK

=SEEK= toc

Description
> In a file opened for Binary access, seek sets a file pointer at the position specified. Data can be read from or written to the file starting at the location of the file pointer. The //position// is the number of bytes, or characters, from the beginning of the file.

> See also LOC(#h).

Syntax

 * 1) seek //#handle, position//

Hints
> //Position// starts at 0.

> It looks like you cannot seek beyond LOF(#h) > This is normal, but because of LOF bug - it wraps over 4GB, > it ends up like this: >> if you have file of 4GB+100 bytes, you will be able to SEEK only in first 100 bytes.

Example
code format="vbnet" ' Usage open "myfile.bin" for binary as #1

'find end of file fpos = lof(#1)

'seek to file position seek #1, fpos

'close the file CLOSE #1 code

Useful Functions
code format="vbnet" sub GetBmpDimensions fileName$, byref width, byref height open fileName$ for binary as #gbd seek #gbd, 18 temp$ = input$(#gbd, 2) width = asc(left$(temp$, 1))+asc(right$(temp$, 1))*256 seek #gbd, 22 temp$ = input$(#gbd, 2) height = asc(left$(temp$, 1))+asc(right$(temp$, 1))*256 close #gbd end sub code