"bad file mode" qbasic 错误
"bad file mode" error in qbasic
我刚开始使用 qbasic 进行文件处理。我写的程序总是报错"bad file mode"。请帮助我!
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
我刚开始使用 qbasic 进行文件处理。我写的程序总是报错"bad file mode"。请帮助我!
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