typestar

Controls made at run time in Igor Pro

A control is created by a command, so a panel can build itself from the data.

Function RebuildChecks(String panelName)
    String existing = ControlNameList(panelName, ";", "chk_*")
    Variable i, n = ItemsInList(existing)

    for (i = 0; i < n; i += 1)
        KillControl/W=$panelName $StringFromList(i, existing)
    endfor

    String waves = WaveList("data_*", ";", "")
    n = ItemsInList(waves)

    for (i = 0; i < n; i += 1)
        String name = StringFromList(i, waves)
        CheckBox $("chk_" + name), win=$panelName, value=1
        CheckBox $("chk_" + name), pos={16, 40 + i * 22}, title=name
    endfor

    return n
End

How it works

  1. ControlNameList is what is there; KillControl removes one.
  2. Positioning arithmetic is how a variable number of controls stays tidy.
  3. Rebuild rather than patch: kill the lot, then make what is needed now.

Keywords and builtins used here

The run, in numbers

Lines
19
Characters to type
493
Tokens
133
Three-star pace
85 tpm

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

Type this snippet

Step 4 of 4 in Bigger controls, step 12 of 18 in Panels & GUI.

← Previous Next →