Killing waves being in use
ChrLie
It would be great to have a flag and a corresponding option for the delete button in the data browser for
KillWaves
to delete waves which are currently being displayed in a graph or table. It's sometimes inconvenient when you work with lots of open graphs or tables to first look through them, remove the wave and just then be able to kill it.
Or did I maybe miss a method to do all this?
Regards
Christian
wave w
string name=nameofwave(w)
string graphs=WinList("*",";","WIN:1") // A list of all graphs
variable i,j
for(i=0;i<itemsinlist(graphs);i+=1)
string graph=stringfromlist(i,graphs)
string traces=TraceNameList(graph,";",3)
if(listmatch(traces,name)) // Assumes that each wave is plotted at most once on a graph.
RemoveFromGraph /W=$graph $name
endif
endfor
string tables=WinList("*",";","WIN:3") // A list of all tables
for(i=0;i<itemsinlist(tables);i+=1)
string table=stringfromlist(i,tables)
j=0
do
string column=StringByKey(table,j)
if(strlen(column))
RemoveFromTable /Z/W=$table $column
j+=1
else
break
endif
while(1)
endfor
killwaves /z w
end
There is no way to kill the wave without killing the graph/table that uses it.
April 14, 2010 at 08:13 am - Permalink
Still, a flag which does it would be nice to have.
Cheers
Christian
April 16, 2010 at 01:12 am - Permalink
wave w
if(waveExists(w))
string name=nameofwave(w)
removeWaveFromAllGraphs(name)
removeWaveFromAllTables(name)
killwaves w
endif
end
function removeWaveFromAllGraphs(name)
string name
string graphs=WinList("*",";","WIN:1") // A list of all graphs
variable isDisplayed
variable i,j
for(i=0;i<itemsinlist(graphs);i+=1)
string graph=stringfromlist(i,graphs)
do
checkDisplayed/w=$graph $name
isDisplayed = V_flag
if(isDisplayed)
RemoveFromGraph /W=$graph $name
endif
while(isDisplayed)
endfor
end
function removeWaveFromAllTables(name)
string name
string tables=WinList("*",";","WIN:2") // A list of all tables
variable i
for(i=0;i<itemsinlist(tables);i+=1)
string table=stringfromlist(i,tables)
checkDisplayed/w=$table $name
if( v_flag == 1)
RemoveFromTable /Z/W=$table $name
endif
endfor
end
August 17, 2012 at 02:36 pm - Permalink
from Igor's Windows->Help Windows->WM Procedures Index help file.
These routines are a little more robust than your code.
Also, version 6.1 of the procedure actually does work in multiple data folders as long as the right flags bit is set in KillMatchingWaves(matchStr, flags).
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
August 17, 2012 at 04:39 pm - Permalink