EasyManuals Logo

Keithley 2651A Reference Manual

Keithley 2651A
800 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 #262 background imageLoading...
Page #262 background image
Section 6: Instrument programming Model 2651A High Power System SourceMeter® Instrument Reference Manual
6-18 2651A-901-01 Rev. A / March 2011
Example: String and number
x = "123"
print(x, type(x))
x = x + 7
print(x, type(x))
123 string
Adding a number to x forces its type to
number
1.30000e+02 number
Example: Function
function add_two(parameter1,
parameter2)
return parameter1 + parameter2
end
print(add_two(3, 4), type(add_two))
7.00000e+00 function
Example: Table
atable = {1, 2, 3, 4}
print(atable, type(atable))
print(atable[1])
print(atable[4])
Defines a table with four numeric
elements.
Note that the "table" value (shown here
as a096cd30) will vary.
table: a096cd30 table
1.00000e+00
4.00000e+00
To delete a global variable, assign nil to the global variable. This removes the global variable from
the runtime environment.
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

Table of Contents

Other manuals for Keithley 2651A

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Keithley 2651A and is the answer not in the manual?

Keithley 2651A Specifications

General IconGeneral
BrandKeithley
Model2651A
CategoryMeasuring Instruments
LanguageEnglish

Related product manuals