repeat/end repeat
Use the repeat/end repeat instruction to describe how to "loop" sections of a script until a particular condition is met.
Usages:
- Execute a set of instructions n times:
repeat <n>
<instructions>
end Repeat - Execute a set of instructions until the device receives a Script trigger:
Repeat until scriptTrigger0
<instructions>
end RepeatWhen the device receives the Script trigger, all instructions remaining in the repeat until loop are completed before advancing, so receipt of the Script trigger does not break out of the repeat loop immediately.
- Execute a set of instructions until the generation operation is aborted (using the
Abort VI/function for your driver).
repeat forever
<instructions>
end repeat - Nest repeat <N> or repeat until instructions inside a repeat forever instruction:
repeat forever
<instructions>
repeat <N>
<instructions>
end repeat
<instructions>
end repeat
or:
repeat forever
<instructions>
repeat until scripttrigger0
<instructions>
end Repeat
<instructions>
end repeatNote You can nest repeat <N> and repeat until instructions, one level deep, inside a repeat forever instruction. The if/else/end if instruction is allowed inside a repeat forever instruction, but if/else/end if is not allowed inside of repeat <N> and repeat until instructions. Other nesting (for example, repeat <N> inside another repeat <N>) is not allowed.
Examples:
- Generate myWfmA followed by myWfmB five times:
repeat 5
generate myWfmA
generate myWfmB
end repeat - Generate the sequence myWfmA, myWfmB, myWfmC until a Script trigger is received:
Repeat until scripttrigger0
generate myWfmA
generate myWfmB
generate myWfmC
end repeat - Generate myWfmA forever (until the operation is aborted):
repeat forever
generate myWfmA
end repeat - Generate continuously the sequence initialWfm once;
myWfmA, myWfmB, myWfmC 1000 times; myWfmD once:
repeat forever
generate initialWfm
repeat 1000
generate myWfmA
generate myWfmB
generate myWfmC
end repeat
generate myWfmD end repeat - Switch between two waveforms upon receipt of a Script trigger (until the operation is aborted):
repeat forever
repeat until scripttrigger0
generate myWfmA
end repeat
repeat until scripttrigger0
generate myWfmB
end repeat
end repeat
Back to Scripting Instructions