Model 2601B-PULSE System SourceMeter Instrument Reference Manual Section 11: TSP command reference
2601B-PULSE-901-01A April 2020 11-83
Also see
waitcomplete() (on page 11-393)
fileVar:close()
This function closes the file that is represented by the fileVar variable.
Usage
fileVar:close()
The file descriptor variable to close
Details
This command is equivalent to io.close(fileVar).
Note that files are automatically closed when the file descriptors are garbage collected.
Example
local fileName = "/usb1/myfile.txt"
if fs.is_file(fileName) then
os.remove(fileName)
print("Removing file")
else
print("Nothing removed")
end
print("\n*** fileVar:close")
do
myfile, myfile_err, myfile_errnum = io.open(fileName, "w")
myfile:write("Line 1")
myfile:close()
end
myfile, myfile_err, myfile_errnum = io.open(fileName, "r")
myfile:close()
os.remove(fileName)
Opens file myfile.txt for writing. If no errors were found while opening, writes Removing file and closes
the file.
Also see
fileVar:flush() (on page 11-84)
fileVar:read() (on page 11-85)
fileVar:seek() (on page 11-86)
fileVar:write() (on page 11-88)
io.close() (on page 11-102)
io.open() (on page 11-104)