Keithley 708B Reference Manual page 210

Switching matrix
Hide thumbs Also See for 708B:
Table of Contents

Advertisement

Models 707B and 708B Switching Matrix Reference Manual
Functions
Lua makes it simple to group commands and statements using the function keyword. Functions
can take zero, one, or multiple parameters, and they return zero, one, or multiple parameters.
Functions can be used to form expressions that calculate and return a value; they also can act as
statements that execute specific tasks.
Functions are first-class values in Lua. That means that functions can be stored in variables, passed
as arguments to other functions, and returned as results. They can also be stored in tables.
Note that when a function is defined, it is a global variable in the runtime environment. Like all global
variables, the functions persist until they are removed from the runtime environment, are overwritten,
or the instrument is turned off.
Create functions using the function keyword
Functions are created with a message or Lua code in the form:
myFunction = function (parameterX) functionBody end
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
Code
function add_two(parameter1, parameter2)
return parameter1 + parameter2
end
print(add_two(3, 4))
707B-901-01 Rev. A / August 2010
Section 6: Instrument programming
Notes and output
Creates a variable named add_two that has a
variable type of function.
7.000000000e+00
6-19

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

707b

Table of Contents