我只是从 qbasic 中的文件处理开始。我编写的程序总是显示错误“错误文件模式”。请帮我!
OPEN "test.dat" FOR INPUT AS #1
CLS
INPUT "Enter username:"; a$
INPUT "Enter Password:"; b$
WRITE #1, a$, b$
CLOSE #1
END
我只是从 qbasic 中的文件处理开始。我编写的程序总是显示错误“错误文件模式”。请帮我!
OPEN "test.dat" FOR INPUT AS #1
CLS
INPUT "Enter username:"; a$
INPUT "Enter Password:"; b$
WRITE #1, a$, b$
CLOSE #1
END
如果你想WRITE
输出到一个文件,那么从逻辑上讲,你可能想试试这个:
OPEN "test.dat" FOR OUTPUT AS #1
CLS
'etc
Qbasic 中一个更具描述性的文件访问示例:
' input data and write to file:
OPEN "test.dat" FOR OUTPUT AS #1
INPUT "Enter Username:"; a$
INPUT "Enter Password:"; b$
WRITE #1, a$, b$
CLOSE #1
' open file for input and display data:
OPEN "test.dat" FOR INPUT AS #1
INPUT #1, a$, b$
PRINT "Username: "; a$
PRINT "Password: "; b$
CLOSE #1
END