Section 11: TSP command reference Model 2601B-PULSE System SourceMeter Instrument Reference Manual
11-88 2601B-PULSE-901-01A April 2020
fileVar:write()
This function writes data to a file.
Usage
fileVar:write(data)
fileVar:write(data1, data2)
fileVar:write(data1, ..., datan)
The file descriptor variable
Write all data to the file
The first data to write to the file
The second data to write to the file
The last data to write to the file
One or more entries (or values) separated by commas
Details
This function may buffer data until a flush (fileVar:flush() or io.flush()) or close
(fileVar:close() or io.close()) operation is performed.
Example
local fileName = "/usb1/myfile.txt"
if fs.is_file(fileName) then
os.remove(fileName)
print("Removing file")
else
print("Nothing removed")
end
errorqueue.clear()
print("\n*** fileVar:write")
myfile, myfile_err, myfile_errnum = io.open(fileName, "w")
do
myfile:write("Line 1")
end
myfile:close()
os.remove(fileName)
Also see
fileVar:close() (on page 11-83)
fileVar:flush() (on page 11-84)
io.close() (on page 11-102)
io.flush() (on page 11-103)
io.open() (on page 11-104)