{{fbdoc item="title" value="OPEN SCRN"}}----
Opens the screen directly for input and output, using it as if it were file operations.

{{fbdoc item="syntax"}}##
	**[[KeyPgOpen|Open]] Scrn** [for //mode//] [[KeyPgAs|as]] [#]//filenumber// [[KeyPgAs|as]] [[KeyPgLong|long]]
##
{{fbdoc item="usage"}}##
	**Open Scrn** [for //mode//] as [#]//filenumber//
		//or//
	//result// = **Open Scrn**( [for //mode//[,]] as [#]//filenumber// )
##
{{fbdoc item="param"}}
	##//mode//##
		Either ##[[KeyPgInputfilemode|Input]]## or ##[[KeyPgOutput|Output]]##.  If omitted, ##[[KeyPgOutput|Output]]## is assumed.
	##//filenumber//##
		An unused file number.

{{fbdoc item="ret"}}
	A 32 bit ##[[KeyPgLong|Long]]##: a zero (##0##) is returned if ##**Open Scrn()**## completed successfully, otherwise a non-zero value is returned to indicate failure.

{{fbdoc item="desc"}}
	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 ##[[KeyPgColor|Color]]## and ##[[KeyPgLocate|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 ##[[KeyPgFreefile|FreeFile]]##.
	
	The error code returned by ##**Open Scrn**## can be checked using ##[[KeyPgErr|Err]]## in the next line. The function version of  ##**Open Scrn**## returns directly the error code as a 32 bit ##[[KeyPgLong|Long]]##.
	
**Runtime errors:**
	##**Open Scrn**## throws one of the following [[ProPgErrorHandling|runtime errors]]:
	
	//(##1##) Illegal function call//
		- ##//filenumber//## was not free at the time. use ##[[KeyPgFreefile|Freefile]]## to ensure that ##//filenumber//## is free.	

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/fileio/openscrn.bas"}}%%(freebasic)
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
%%

{{fbdoc item="diff"}}
	- QB used OPEN "SCRN:" ...

{{fbdoc item="see"}}
	- ##[[KeyPgOpen|Open]]##
	- ##[[KeyPgOpenCons|Open Cons]]##

{{fbdoc item="back" value="CatPgFile|File I/O Functions"}}