typestar

Working with text in Igor Pro

Igor's string toolkit is small and every piece of it is a function.

Function/S CleanName(String raw)
    String name = TrimString(raw)
    name = ReplaceString(" ", name, "_")
    name = LowerStr(name)

    if (strlen(name) == 0)
        return "unnamed"
    endif

    if (StringMatch(name, "temp*"))
        name = "scratch_" + name
    endif

    return name
End

How it works

  1. strlen, cmpstr and stringmatch measure and compare.
  2. num2str and str2num cross between text and numbers.
  3. ReplaceString and UpperStr return a new string, as everything does.

Keywords and builtins used here

The run, in numbers

Lines
15
Characters to type
249
Tokens
60
Three-star pace
75 tpm

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

Type this snippet

Step 1 of 4 in Text, step 12 of 18 in Language basics.

← Previous Next →