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
eventCode1 is enter, 2 is arrows or mouse, 3 is a live edit.sva.dvalcarries the number;sva.svalthe string.- Returning zero is the convention; the value is ignored.
Keywords and builtins used here
EndFunctionNVARPrintfSTRUCTendififlimitreturn
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.
Step 2 of 5 in Values a user sets, step 5 of 18 in Panels & GUI.