EasyManuals Logo

Keithley 2612B Reference Manual

Keithley 2612B
864 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 #301 background imageLoading...
Page #301 background image
Section
6: Instrument programming Series 2600B System SourceMeter® Instrument
Reference Manual
6-24 2600BS-901-01 Rev. B / May 2013
Break
The break statement can be used to terminate the execution of a while, repeat, or for loop,
skipping to the next statement after the loop. A break ends the innermost enclosing loop.
Return and break statements can only be written as the last statement of a block. If it is necessary to
return or break in the middle of a block, an explicit inner block can be used.
The output you get from these examples may vary depending on the data format settings of the
instrument.
Example: Break with while statement
local numTable = {5, 4, 3, 2, 1}
local k = table.getn(numTable)
local breakValue = 3
while k > 0 do
if numTable[k] == breakValue then
print("Going to break and k = ", k)
break
end
k = k - 1
end
if k == 0 then
print("Break value not found")
end
This example defines a break value
(breakValue) so that the break
statement is used to exit the while loop
before the value of k reaches 0.
Output:
Going to break and k = 3
Example: Break with while statement enclosed by comment delimiters
local numTable = {5, 4, 3, 2, 1}
local k = table.getn(numTable)
--local breakValue = 3
while k > 0 do
if numTable[k] == breakValue then
print("Going to break and k = ", k)
break
end
k = k - 1
end
if k == 0 then
print("Break value not found")
end
This example defines a break value
(breakValue), but the break value
line is preceded by comment delimiters
so that the break value is not
assigned, and the code reaches the
value 0 to exit the while loop.
Output:
Break value not found

Table of Contents

Other manuals for Keithley 2612B

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Keithley 2612B and is the answer not in the manual?

Keithley 2612B Specifications

General IconGeneral
BrandKeithley
Model2612B
CategoryMeasuring Instruments
LanguageEnglish

Related product manuals