QBasic を使用してバッチ ファイル、テキスト ファイル、および DLL ファイルを作成しようとしていますか?
助けてください...偽のDOSを作っています。
QBasic を使用してバッチ ファイル、テキスト ファイル、および DLL ファイルを作成しようとしていますか?
助けてください...偽のDOSを作っています。
それは古いです:)
私が思い出した場合:
ファイルを開くには: (作成、読み取り、書き込みが可能)
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