BOpen Statement
Opens file in binary mode.
Syntax
BOpen fileName As #fileNumber
.
.
Close #fileNumber
Parameters
- fileName
- Specify a string containing the path and file name. If path is omitted, the file in the current directory is specified. See ChDisk for the details.
- fileNumber
- Specify an integer value from 30 to 63 or an expression.
Description
Opens the specified file and identifies it by the specified file number. This statement is used for accessing the specified file in binary mode. If the specified file is not found, it will create a new file. If the file exists, it will read and write the data from the beginning. Use the ReadBin and WriteBin commands to read and write data in binary mode.
Note
A network path is available.
The specified fileNumber identifies the file while it is open and cannot be used to refer to a different file until the current file is closed. fileNumber is used by other file operations such as ReadBin, WriteBin, Seek, Eof, Flush, and Close.
The read/write position (pointer) of the file can be changed using the Seek command. When switching between read and write access, use Seek to reposition the file pointer.
Use the Close statement to close the file and release the file number.
It is recommended that you use the FreeFile function to obtain the file number so that more than one task are not using the same number.
See Also
Close, AOpen, FreeFile, ReadBin, ROpen, UOpen, WOpen, WriteBin
BOpen Statement Example
Integer fileNum, i
fileNum = FreeFile
BOpen "TEST.DAT" As #fileNum
For i = 0 To 100
WriteBin #fileNum, i
Next i
Flush #fileNum
Seek #fileNum, 10
ReadBin #fileNum, i
Print "data = ", i
Close #fileNum