UOpen Statement
Opens a file for read / write access.
Syntax
UOpen 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 by the specified file number. This statement is used for writing and loading data in the specified file.
Note
A network path is available.
If the specified file does not exist on disk, the file will be created and the data will be written into it. If the specified file already exists on disk, the data will be written and read starting from the beginning of the existing data.
The read/write position (pointer) of the file can be changed using the Seek command. When switching between read and write access, you must use Seek to reposition the file pointer.
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 Print#, Input#, Read, Write, Seek, and Close.
Close closes the file and releases 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, Print #, Input#, AOpen, BOpen, ROpen, WOpen, FreeFile, Seek
UOpen Statement Example
Integer fileNum, i, j
fileNum = FreeFile
UOpen "TEST.DAT" As #fileNum
For i = 0 To 100
Print #fileNum, i
Next i
Close #fileNum
fileNum = FreeFile
UOpen "TEST.DAT" As #fileNum
Seek #fileNum, 10
Input #fileNum, j
Print "data = ", j
Close #fileNum