我正在尝试通过QBasic创建批处理文件、文本文件和DLL文件。
请帮帮我。我在做一个假的DOS。
发布于 2015-08-04 02:42:43
这是旧的:)
如果我提醒你:
打开文件:(您可以创建、读取和写入)
Open (Path and file name) For (Mode) [Access (Type of access)] As #(File number)其中:
(路径和文件名)-目标文件的路径和名称
(模式)-可以设置下列值之一:
Input: Read Mode
Binary: Structured data
Output: Write Mode - If the file already exist - overwrites the file.
Append: The difference between this and Output is that if the file already exists, the content is appended to the end of the file(访问类型)-访问类型。
Read: Read-Only access.
Write: Write-Only access.
Read Write: Available only in Append Mode(文件号)-标识文件,就像指向该文件的指针一样。
要关闭文件,只需使用:
Close [#(FileNumber)][, #(FileNumber) ...]是的,你可以一次关闭多个文件,如果你不指定文件号,qbasic将关闭所有打开的文件。
请注意,在追加和输出模式下,您必须先关闭文件,然后才能打开它进行读取!
好的,要读\写,使用与屏幕上相同的方法,但附加文件目标:
Input (Char Length), #(File number), (Name of the Variable)
Line Input #(File number), (Name of the Variable)
Print #(File number), (Data) [or (Binary data)] 如果您不记得提供回车符(通常是\n),请使用ASCII char: Chr(10)
示例:
Open "c:\test.bat" for Output as #1
Print #1, "@echo off" + Chr$(10)
Print #1, "echo Hello World"
Close #1
Endhttps://stackoverflow.com/questions/31793883
复制相似问题