Can't update a control programmatically

Using the same panel from my previous question: https://www.wavemetrics.com/forum/general/how-poll-all-controls-when-interacting-any-control

I would like the "Probe 1 run" and "Probe 2 run" to update to either "1" or "n/a" depending on if there is data available for those probes. That is, it should default to the first replicate experiment wave if it exists, or display "n/a" and disable if it isn't.

Here's the code I've tried, which is nearly identical to the snippet for Probe 1:

string matchProbe2 = WaveList(prefix,";","")
variable numProbe2Replicates = ItemsInList(matchProbe2, ";")
if (numProbe2Replicates == 0)
   print "No Probe2 data found for this experiment."
   PopupMenu Probe2SelectPopup,win=smp0,value="n/a",disable=2,popvalue="n/a"
   wave z = root:Processing:InputData:Probe2Data
   z = 0
else
   String nry = makeValueString(numProbe2Replicates)
   PopupMenu Probe2SelectPopup,win=smp0,value=#nry,disable=0,popvalue="1" 
endif
ControlUpdate/W=smp0 Probe2SelectPopup

This does not work. This disables or enables the popups just fine, but it does not set the display value. I don't so much care about displaying "n/a" when the popup is disabled, but it's pretty crucial that the popup revert to the first replicate if it exists, since that feeds forward into further processing.

panel

I suggest that you probably must include a mode= setting in the popupmenu command.

jjweimer is right- use the "mode=<one-based menu item number>" keyword to control what appears as selected in the menu. That implies that one of the menu items needs to be "n/a" to allow you to select that item. The presence of a "/" may cause trouble- it would be better to use "Not Applicable".

Another bit of advice: don't use the `popvalue` keyword. It was invented for a very specific purpose. In my experience, it only causes trouble. I think it was a misfeature invented to solve a non-problem. If you really want to know more detail, I can provide it :)

Here is a short bit of code to do the change.

Function reset_PopUp(string prefix)
    string mList, wList = WaveList(prefix, ";","")
    variable ds, nitems = ItemsInList(wList)
    if (nitems == 0)
        mList = "--;"
        ds = 2
    else
        mList = makeValueString(nitems)
        ds = 0
    endif
    PopupMenu Probe2SelectPopup, win=smp0, value=#mList, mode=1, disable=(ds)
    ControlUpdate ...
    return 0
end