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 は開いているすべてのファイルを閉じます。

追加モードと出力モードでは、読み取りのためにファイルを開く前に、まずファイルを閉じる必要があることに注意してください。

OK、読み書きするには、画面で使用するのと同じものを使用しますが、ファイルの宛先を追加します。

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
End
于 2015-08-03T18:42:43.023 に答える