Revision [17579]

This is an old revision of KeyPgOpenCons made by FxMwikki on 2015-04-04 06:42:43.



Opens the console's standard input (stdin) or output (stdout) streams for use in file operations.

Open Cons As [#]filenumber
Open Cons For KeyPgInputfilemode Input As [#]filenumber
Open Cons For KeyPgOutput Output As [#]filenumber

result = Open Cons( [For {KeyPgInputfilemode Input|KeyPgOutput Output}[,]] As filenumber )
(or using the QB-like syntax,)
Open Cons [For {KeyPgInputfilemode Input|KeyPgOutput Output}] As filenumber

An available file number to bind to the stdin or stdout stream, which can be found with KeyPgFreefile Freefile.

Return Value:
In the first usage, Open Cons returns zero (0) on success and a non-zero error code otherwise.

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 KeyPgInputPp Input #. An available file number can be retrieved with KeyPgFreefile Freefile.
The KeyPgInputfilemode Input file mode opens the stdin stream for reading file operations, such as KeyPgInputPp Line Input #, while the KeyPgOutput Output file mode opens the stdout stream for writing file operations, such as KeyPgPrintPp Print #. The KeyPgOutput 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 KeyPgOpenPipe Open Pipe.
To open both the stdin and stdout streams for file operations, a process must use multiple file numbers.

Runtime errors:
Open Cons throws one of the following ProPgErrorHandling runtime errors:
(1) Illegal function call

Dim a As String

Open Cons For Input As #1
Open Cons For Output As #2

Print #2,"Please write something and press ENTER"
Line Input #1,a
Print #2, "You wrote : ";a


Differences from QB:
See also:
Back to File I/O Functions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode