Open Cons opens the console's
stdin or
stdout streams for reading or writing. A
file number is bound to the stream, which is used in subsequent file operations, such as
Input #. An available
file number can be retrieved with
FreeFile.
The
Input file mode opens the
stdin stream for reading file operations, such as
Line Input #, while the
Output file mode opens the
stdout stream for writing file operations, such as
Print #. The
Output file mode is the default if not specified.
The
stdin and
stdout streams are the ones used when the calling process' input or output is redirected (piped) by OS commands, or when it is opened with
Open Pipe.
To open both the
stdin and
stdout streams for file operations, a process must use multiple
file numbers.
The normal screen commands, such as
Color and
Locate, do not work in this mode, because they do not accept a file number.
The
Tab keyword, regardless of the given column number, is always interpreted as a simple comma (
,) (next output will take place at the next 14 column boundary).
The error code returned by
Open Cons can be checked using
Err in the next line. The function version of
Open Cons returns directly the error code as a 32 bit
Long.
Warning: Presently,
Open Cons does not work as described above. Without any
file mode specifier, a runtime error 1 (illegal function call) occurs. With the
Input file mode specifier, the only input mode is well supported. But with the
Output file mode specifier, input and output modes are simultaneously supported.
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.