Section 11: TSP command reference Model 2601B-PULSE System SourceMeter Instrument Reference Manual
11-86 2601B-PULSE-901-01A April 2020
Example
local fileName = "/usb1/myfile.txt"
if fs.is_file(fileName) then
os.remove(fileName)
print("Removing file")
else
print("Nothing removed")
end
print("fileVar:read")
myfile, myfile_err, myfile_errnum = io.open(fileName, "w")
myfile:write("Line 1")
myfile:close()
do
myfile, myfile_err, myfile_errnum = io.open(fileName, "r")
contents = myfile:read("*a")
print(contents)
end
myfile:close()
os.remove(fileName)
Reads data from the input file.
Also see
fileVar:write() (on page 11-88)
io.input() (on page 11-104)
io.open() (on page 11-104)
fileVar:seek()
This function sets and gets the present position of a file.
Usage
position, errorMsg = fileVar:seek()
position, errorMsg = fileVar:seek("whence")
position, errorMsg = fileVar:seek("whence", offset)
The new file position, measured in bytes from the beginning of the file
A string containing the error message
The file descriptor variable
A string indicating the base against which offset is applied; the default is "cur"
The intended new position, measured in bytes from a base indicated by whence
(default is 0)