Generate Menu String Based on Package Existing (with Panel Shown)
This code will build a menu return string to call a function in a package based on input for three options
- Does a graph window exist?
- Does a specific function exist that defines the entrance point for a specific package?
- [optional] Is a specific panel that is associate with the package already showing?
Function/S BuildMenuStr(string package, string rStr, [string actpanel])
string fWin = WinName(0,1)
if (ParamIsDefault(actpanel))
if ((strlen(fWin) == 0) || (exists(package) == 0))
rStr = "\\M1(" + rStr
endif
else
if ((strlen(fWin) == 0) || (exists(package) == 0))
rStr = "\\M1(" + rStr
else
if (ItemsInList(WinList(actpanel,";","WIN:64")) != 0)
rStr = "\\M1(" + rStr + " (active)"
endif
endif
endif
return rStr
end
By example, using Tony's Baselines package, I call this in one of my analysis package menu options.
BuildMenuStr("Baselines#Initialise","Generate Baselines",actpanel="BL_panel"), /Q, StartBaselines()
The menu return appears as
--> INACTIVE Generate Baselines - cannot select when front window is not a graph or baselines package is not loaded
--> ACTIVE Generate Baselines - can select when front window is a graph, baselines package is loaded, and baselines is not active on front window
--> INACTIVE Generate Baselines (active) - cannot select because front graph window already has baselines panel attached
EDIT -- A more secure approach is to check for the panel in WinList(...), since this returns it whether it is external or not.
Forum
Support
Gallery
Igor Pro 10
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More