typestar

Wave references in Igor Pro

A WAVE reference is how a function holds onto a wave without knowing its name.

Function Process(String name)
    WAVE/Z src = $name

    if (!WaveExists(src))
        Print "no wave called", name
        return -1
    endif

    Duplicate/O src, $(name + "_smooth")
    WAVE dest = $(name + "_smooth")
    Smooth 5, dest

    return 0
End

How it works

  1. WAVE w = name binds a reference; $ binds one from a string.
  2. WaveExists is the check to make before using one.
  3. /Z on the reference stops the compiler complaining when it may be missing.

Keywords and builtins used here

The run, in numbers

Lines
14
Characters to type
215
Tokens
53
Three-star pace
70 tpm

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

Type this snippet

Step 3 of 4 in Waves, step 3 of 18 in Language basics.

← Previous Next →