Open Scrn
Opens the console directly for input and output as a file
Open Scrn [for mode] as [#]filenum
Zero (0) is returned if Open Err completed successfully, otherwise a non-zero value is returned to indicate failure.
This command opens the console for both input and output as a file, allowing to read/write from/to it with normal file commands.
This command may use direct access to the console for speed in some implementations, so it should not be used when the input / output is required to be redirected or piped with OS commands.
The normal console commands, such as Color and Locate, do not work in this mode, because they do not accept a file number.
The [For Input|Output] clause is allowed for compatibility, but is ignored.
filenum is an unused file number.
An unused file number can be found using FreeFile.
Runtime errors:
Open Cons throws one of the following runtime errors:
(1) Illegal function call
Syntax
Usage
Open Scrn [for mode] as [#]filenum
or
result = Open Scrn( [for mode[,]] as [#]filenum )Parameters
Return Value
Zero (0) is returned if Open Err completed successfully, otherwise a non-zero value is returned to indicate failure.
Description
This command opens the console for both input and output as a file, allowing to read/write from/to it with normal file commands.
This command may use direct access to the console for speed in some implementations, so it should not be used when the input / output is required to be redirected or piped with OS commands.
The normal console commands, such as Color and Locate, do not work in this mode, because they do not accept a file number.
The [For Input|Output] clause is allowed for compatibility, but is ignored.
filenum is an unused file number.
An unused file number can be found using FreeFile.
Runtime errors:
Open Cons throws one of the following runtime errors:
(1) Illegal function call
- filenumber was not free at the time. use FreeFile to ensure that filenumber is free.
Example
Dim a As String
Open Scrn For Input As #1
Print #1,"Please write something and press ENTER"
Line Input #1,a
Print #1, "You wrote";a
Close
Sleep
Open Scrn For Input As #1
Print #1,"Please write something and press ENTER"
Line Input #1,a
Print #1, "You wrote";a
Close
Sleep
Differences from QB
- QB used OPEN "SCRN:" ...
See also