4-161
Detailed explanation of command words
4MELFA-BASIC IV
Close (Close)
[Function]
Closes the designated file.(including communication lines)
[Format]
[Terminology]
<File No.>
Specify the number of the file to be closed (1 to 8). Only a numerical constant is allowed.
If this argument is omitted, all open files are closed.
[Reference Program]
1 Open "COM1:" AS #1
' "Open "COM1:" as file No. 1.
2 Print #1,M1
:
10 Input #1,M2
11 Close #1
' Close file No. 1, "COM1:".
:
20 Close
' Close all open files.
[Explanation]
(1) This instruction closes files (including communication lines) opened by the Open instruction. Data
remaining in the buffer is flushed.
The data left in the buffer will be processed as follows when the file is closed:
Table 4-14:Processing of each buffer when the file is closed
(2) Executing an End statement will also close a file.
(3) If the file number is omitted, all files will be closed.
[Related instructions]
Close[] [[#]<File No.>[, [[#]<File No.> ...]
Buffer types
Processing when the file is closed
Communication line reception buffer
The contents of the buffer are destroyed
Communication line transmission
buffer
(No data remains in the transmission buffer since the data in the transmission
buffer is sent immediately by executing the Print instruction.)
File load buffer
The contents of the buffer are destroyed.
File unload buffer
The contents of the buffer are written into the file, and then the file is closed.