Series 2600B System SourceMeter® instrument Reference Manual Section 9: TSP command reference
2600BS-901-01 Rev. F/August 2021 9-97
Details
The format parameters may be any of the following:
"*n": Returns a number.
"*a": Returns the whole file, starting at the current position (returns an empty string if the current file
position is at the end of the file).
"*l": Returns the next line, skipping the end of line; returns nil if the current file position is at the
end of file.
n: Returns a string with up to n characters; returns an empty string if n is zero; returns nil if the
current file position is at the end of file.
If no format parameters are provided, the function performs as if the function is passed the value
"*l".
Any number of format parameters may be passed to this command, each corresponding to a returned
data value.
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 9-99)
io.input() (on page 9-118)
io.open() (on page 9-119)