Keithley 2651A Reference Manual page 263

High power system sourcemeter instrument
Hide thumbs Also See for 2651A:
Table of Contents

Advertisement

Model 2651A High Power System SourceMeter® Instrument Reference Manual
Where:
myFunction: The name of the function
parameterX: Parameter values. You can have multiple parameters. Change the value defined
by X for each parameter and use a comma to separate the values.
functionBody is the code that is executed when the function is called
To execute a function, substitute appropriate values for parameterX and insert them into a message
formatted as:
myFunction(valueForParameterX, valueForParameterY)
Where valueForParameterX and valueForParameterY represent the values to be passed to
the function call for the given parameters.
Example 1
function add_two(parameter1, parameter2)
return parameter1 + parameter2
end
print(add_two(3, 4))
Example 2
add_three = function(parameter1,
parameter2, parameter3)
return parameter1 + parameter2 +
parameter3
end
print(add_three(3, 4, 5))
Example 3
function sum_diff_ratio(parameter1,
parameter2)
psum = parameter1 + parameter2
pdif = parameter1 - parameter2
prat = parameter1 / parameter2
return psum, pdif, prat
end
sum, diff, ratio = sum_diff_ratio(2, 3)
print(sum)
print(diff)
print(ratio)
2651A-901-01 Rev. A / March 2011
Section 6: Instrument programming
Creates a variable named add_two that
has a variable type of function.
Output:
7.000000000e+00
Creates a variable named add_three
that has a variable type of function.
Output:
1.200000000e+01
Returns multiple parameters (sum,
difference, and ratio of the two numbers
passed to it).
Output:
5.000000000e+00
-1.000000000e+00
6.666666667e-01
6-19

Advertisement

Table of Contents
loading

Table of Contents