EasyManuals Logo

Keithley SourceMeter 2600 Series User Manual

Keithley SourceMeter 2600 Series
594 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #58 background imageLoading...
Page #58 background image
2-6 TSP Programming Fundamentals Series 2600 System SourceMeters Reference Manual
2600S-901-01 Rev. A / May 2006 Return to Section 2 topics
Functions are created with a message in one of the following forms:
MyFunction = function (parameter1, parameter2) function body end
or
function MyFunction(parameter1, parameter2) function body end
Where function body is a TSP chunk that will be executed when the function is
called. The above function can be executed by sending the following message:
MyFunction(value for parameter1, value for parameter2)
Where value for parameterN are the values to be passed to the function call
for the given parameters. Note that when a function is defined, it is just another
global variable in the run-time environment. Just like all global variables, functions
will persist until it is removed from the run-time environment, overwritten, or the
unit is turned off.
Scripts that create functions
It is inconvenient in most cases to define a function in one message. The solution
is to create a script that defines a function. The scripts will be like any other script.
It will not cause any action to be performed on the instrument until it is executed.
Remember that creating a function is just creating a global variable that is a
function. That global variable will not exist until the chunk that creates it is
executed. In this case the chunk that creates it is a script. Therefore, the function
will not exist until the script that creates it is executed. This is often confusing to
first time users.
Example: Create the function MyFunction with a script named MakeMyFunction.
The sequence of messages to do this is shown as follows:
loadscript MakeMyFunction
MyFunction = function (who) --The .. operator concatenates two strings.
print("Hello " .. who)
end
endscript
After this sequence of messages is sent, the MakeMyFunction script exists on the
instrument in a global variable named
MakeMyFunction. The MyFunction function
however does not yet exist because we have not executed the
MakeMyFunction
script. Let us now send the message
MakeMyFunction(). That message instructs
the instrument to run the
MakeMyFunction script which then creates the
MyFunction global variable that happens to be a function.
If we now send the message MyFunction("world"), the instrument will execute
the
MyFunction function, which causes the instrument to generate a response
message with the text “Hello world” in it.

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Keithley SourceMeter 2600 Series and is the answer not in the manual?

Keithley SourceMeter 2600 Series Specifications

General IconGeneral
BrandKeithley
ModelSourceMeter 2600 Series
CategoryMeasuring Instruments
LanguageEnglish

Related product manuals