typestar

Finding the right window in Igor Pro

A function that acts on the front graph has to ask which one that is.

Function TidyGraphs()
    String graphs = WinList("*", ";", "WIN:1")
    Variable i, n = ItemsInList(graphs)

    for (i = 0; i < n; i += 1)
        String name = StringFromList(i, graphs)
        DoWindow/F $name
        GetWindow $name, wsize
        MoveWindow/W=$name 40 + i * 20, 40 + i * 20, V_right, V_bottom
    endfor

    Printf "%d graphs, front is %s\r", n, WinName(0, 1)
End

How it works

  1. WinName(0, 1) is the front graph; the second argument is the type mask.
  2. WinList gives every window of a kind, as a list.
  3. DoWindow/F brings one forward; GetWindow reads its geometry.

Keywords and builtins used here

The run, in numbers

Lines
13
Characters to type
335
Tokens
86
Three-star pace
90 tpm

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

Type this snippet

Step 3 of 3 in Off the screen, step 18 of 19 in Graphs & presentation.

← Previous Next →