typestar

Text waves in Igor Pro

A text wave holds strings, and most numeric operations do not apply to it.

Function/WAVE LabelWaves(WAVE values, Variable cut)
    Make/O/T/N=(numpnts(values)) labels
    WAVE/T labels

    labels = SelectString(values[p] > cut, "low", "high")
    labels[0] = "reference"

    Variable high = 0
    high = sum(values, 0, inf) > cut ? 1 : 0
    String overall = SelectString(high, "low", "high")
    Printf "first label %s, overall %s\r", labels[0], overall

    return labels
End

How it works

  1. Make/T makes one; WAVE/T is the reference type.
  2. Assignment works the same way, with p indexing the points.
  3. SelectString is the string answer to the ternary operator.

Keywords and builtins used here

The run, in numbers

Lines
14
Characters to type
368
Tokens
89
Three-star pace
75 tpm

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

Type this snippet

Step 4 of 4 in Text, step 15 of 18 in Language basics.

← Previous Next →