List Objects where a wave is shown
flashbanger
Wed, 06/13/2018 - 12:20 pm
Hello everyone,
i have a simple question. Is it possible to get a List of all Windows, where a specific wave is shown?
The DataBrowser has this feature by performing a right-click on a wave and selecting "Show where Object is used ..", but i wasn't able to find a Igor-function that is giving me that list from the program language. I know that there is the option to use "CheckDisplayed" for every window, but this seems to be quite awkward.
Best regards,
Flashbanger
June 13, 2018 at 06:44 pm - Permalink
// Selected wave in the data browser can be in any datafolder (doesn't have to be current datafolder).
macro FindSelectedWave()
FindWindowContainingSelWave()
end
function FindWindowContainingSelWave()
string fullSelection, wToFind, windowList, windowName, DFpath, savedDataFolder, foundWindows
variable n, num
if(DataFolderExists(GetBrowserSelection(0)))
Abort "Please click on a wave, not a datafolder."
endif
savedDataFolder = GetDataFolder(1) //current data folder
fullSelection = GetBrowserSelection(0) //wave selected
wToFind = ParseFilePath(0, fullSelection, ":", 1, 0) //get the wave name only (removes datafolders if any)
DFpath = ParseFilePath(1, fullSelection, ":", 1, 0) //get datafolder path to that wave
SetDataFolder DFpath //set datafolder to the one containing the selected wave
Print "Searching for wave ",fullSelection
foundWindows = "" //init
windowList = WinList("*", ";","WIN:3") //list of all tables and graphs
num = ItemsInList(windowList)
for(n=0; n<num; n+=1) //loop thru them all to find which one has wave in use
windowName = StringFromList(n, windowList) //get a window name
if (strlen(wavelist(wToFind, ";", "WIN:"+windowName))>0) //if the wavelist command returns a string, this window has the wave in it.
foundWindows+= windowName+";"
endif
endfor
if (strlen(foundWindows)==0) //if loop index has incremented to num, then wave wasn't found in any graph or table.
Print "Wave ",wToFind, "is not in use."
else
Print "Wave is used in window(s) ", foundWindows
DoWindow/F $(StringFromList(0, foundWindows)) // bring first window containing wave to front, but could do them all in loop
endif
SetDataFolder savedDataFolder //set datafolder back to original setting.
end
June 14, 2018 at 08:05 am - Permalink