File.read() - Keithley 2450 Reference Manual

Interactive sourcemeter instrument
Table of Contents

Advertisement

Section 8: TSP command reference
Example
file_num = file.open("testfile.txt",
file.MODE_WRITE)
if file_num != nil then
file.write(file_num,"This is my test file")
file.close(file_num)
end
Also see
None

file.read()

This function reads data from a file.
Type
TSP-Link accessible
Function
No
Usage
fileContents = file.read(fileNumber, readAction)
fileContents
fileNumber
readAction
Details
This command reads data from a file.
Example
file_num = file.open("/usb1/testfile.txt",
file.MODE_READ)
if file_num
file_contents = file.read(file_num, file.READ_ALL)
file.close(file_num)
end
Also see
None
8-60
Model 2450 Interactive SourceMeter® Instrument Reference Manual
Affected by
The contents of the file based on the readAction parameter
The file number from file open command of the file to read
The action to do:
Return the next line; returns nil if the present file position is at the end of the
file: file.READ_LINE
Return 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:
file.READ_NUMBER
Return the whole file, starting at the present position; returns an empty string
if the present file position is at the end of the file: file.READ_ALL
!= nil then
Opens file testfile.txt for
writing. If no errors were found
while opening, writes "This is
my test file" and closes the
file.
Where saved
Default value
Open testfile.txt on the
thumb drive for reading. If it
opens successfully, read the
entire contents of the file and
store it in variable
file_contents.
Close the file.
2450-901-01 Rev. B/September 2013

Advertisement

Table of Contents
loading

Table of Contents