typestar

Reacting to an edit in Igor Pro

A SetVariable action fires on every kind of change, so check which one you got.

Function ThresholdChanged(STRUCT WMSetVariableAction &sva) : SetVariableControl
    if (sva.eventCode != 1 && sva.eventCode != 2)
        return 0
    endif

    NVAR threshold = root:Settings:gThreshold
    threshold = limit(sva.dval, 0, 10)

    Printf "threshold is now %g\r", threshold
    return 0
End

How it works

  1. eventCode 1 is enter, 2 is arrows or mouse, 3 is a live edit.
  2. sva.dval carries the number; sva.sval the string.
  3. Returning zero is the convention; the value is ignored.

Keywords and builtins used here

The run, in numbers

Lines
11
Characters to type
274
Tokens
54
Three-star pace
85 tpm

At the three-star pace of 85 tokens a minute, this run takes about 38 seconds.

Type this snippet

Step 2 of 5 in Values a user sets, step 5 of 18 in Panels & GUI.

← Previous Next →