1

我正在尝试通过 QBasic 创建批处理文件、文本文件和 DLL 文件?

请帮帮我...我正在制作一个假的DOS。

4

1 回答 1

5

那是旧的:)

如果我提醒:

打开文件:(您可以创建、读取和写入)

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 字符:Chr(10)

例子:

Open "c:\test.bat" for Output as #1
Print #1, "@echo off" + Chr$(10)
Print #1, "echo Hello World"
Close #1
End
于 2015-08-03T18:42:43.023 回答