Interactive script
An interactive script prompts the operator to input values using the instrument front panel. The
following example script uses display messages to prompt the operator to:
• Enter the digital I/O line on which to output a trigger
• Enter the output trigger pulsewidth
After the output trigger occurs, the front display displays a message to the operator.
When an input prompt is displayed, the script waits until the operator inputs the parameter or presses
the ENTER key.
The example shown here assumes that you are using TSB or TSB Embedded. If you are using a
remote interface, you need to add the loadscript and endscript commands to the example
code. See Load a script by sending commands over the remote interface (on page 10-4) for details.
-- Clear the display.
display.clear()
-- Prompt user for digital I/O line on which to output trigger.
myDigioLine = display.menu("Select digio line", "1 2 3 4 5 6 7 8 9")
-- Convert user input to a number.
intMyDigioLine = tonumber(myDigioLine)
-- Prompt user for digital output trigger mode.
myDigioEdge = display.menu("Select digio mode", "Rising Falling")
if myDigioEdge == "Rising" then
edgeMode = digio.TRIG_RISING
else
edgeMode = digio.TRIG_FALLING
end
-- Prompt user for output trigger pulsewidth.
myPulseWidth = display.prompt(
"000.0", "us", "Enter trigger pulsewidth", 10, 10, 100)
-- Scale the entered pulsewidth.
myPulseWidth = myPulseWidth * 1e-6
-- Generate the pulse.
digio.trigger[intMyDigioLine].mode = edgeMode
digio.trigger[intMyDigioLine].pulsewidth = myPulseWidth
digio.trigger[intMyDigioLine].assert()
-- Alert the user through the display that the
-- output trigger has occurred.
display.setcursor(1, 1)
display.settext("Trigger asserted $Non digital I/O line " .. intMyDigioLine)
-- Wait five seconds and then return to main screen.
delay(5)
display.screen = display.MAIN