RESET
- 来源: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgReset
- 最后更新: 2016-03-13
关闭所有打开的文件,或重置标准I/O句柄。
语法
vb
declare sub Reset ( )
declare sub Reset ( byval streamno as long )用法
Reset
or
Reset( streamno )参数
streamno
要重置的流编号,0 表示 stdin,1 表示 stdout。
说明
不带参数调用 Reset 时,关闭所有磁盘文件。
带 streamno 参数调用 Reset 时,将重置与 stdin(0)或 stdout(1)关联的重定向或管道流。
运行时错误: Reset(streamno) 可以设置以下运行时错误之一:
(1) 非法函数调用
streamno不是0也不是1
(3) 文件I/O错误
- 重置 stdin 或 stdout 失败
示例
start GeSHi
vb
Open "test.txt" For Output As #1
Print #1, "testing 123"
Resetend GeSHi
start GeSHi
vb
Dim x As String
'' Read from STDIN from piped input
Open Cons For Input As #1
While EOF(1) = 0
Input #1, x
Print """"; x; """"
Wend
Close #1
'' Reset to read from the keyboard
Reset(0)
Print "Enter some text:"
Input x
'' Read from STDIN (now from keyboard)
Open Cons For Input As #1
While EOF(1) = 0
Input #1, x
Print """"; x; """"
Wend
Close #1end GeSHi
注意:在 Windows 下,要告知程序数据输入已完成(传输 EOF),可以按 CTRL+Z 然后按 ENTER。
与QB的区别
Reset()无差异。Reset(streamno)的用法是 FreeBASIC 新增的。
参见
CloseOpenOpen ConsIsRedirected
返回 目录