QBasic - 如何在QBasic中创建任何类型的文件?

问题描述 投票:1回答:1

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

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

dos file-management qbasic
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将关闭所有打开的文件。

请注意,在“附加”和“输出”模式下,必须先关闭该文件,然后才能打开它进行读取!

好的,读取\ write使用你在屏幕上使用的相同,但附加文件目的地:

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
© www.soinside.com 2019 - 2024. All rights reserved.