OPEN SCRN
- Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOpenScrn
- Last revised: 2023-06-24
Opens the screen directly for input and output, using it as if it were file operations.
Syntax
` Open Scrn [for mode] as [#]filenumber as long
`
Usage
Open Scrn [for mode] as [#]filenumber
or
result = Open Scrn( [for mode[,]] as [#]filenumber )Parameters
mode
Either Input or Output. If omitted, Output is assumed.
filenumber
An unused file number.
Return Value
A 32 bit Long: a zero (0) is returned if Open Scrn() completed successfully, otherwise a non-zero value is returned to indicate failure.
Description
This command opens the screen (in text or graphics screen mode) 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 screen 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 screen 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.
filenumber is an unused file number.
An unused file number can be found using FreeFile.
The error code returned by Open Scrn can be checked using Err in the next line. The function version of Open Scrn returns directly the error code as a 32 bit Long.
Runtime errors: Open Scrn throws one of the following runtime errors:
(1) Illegal function call
filenumberwas not free at the time. useFreefileto ensure thatfilenumberis free.
Examples
start GeSHi
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
Sleepend GeSHi
Differences from QB
- QB used OPEN "SCRN:" ...
See also
OpenOpen Cons
Back to DocToc