Killing waves being in use

I'm not sure if this came up before.

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
In the graph browser (Misc / Graph Browser), you can enter the name of a wave, with wild cards, and find a list of graphs/tables which use that wave. Then you can kill those graphs/tables, and then kill the wave. It is also possible to write a function which looks through all graphs/tables to find which ones use your wave, removes that wave from the graphs and tables, and then kills the wave. It would look something like this, although I haven't tested it:
function ReallyKillWaves(w)
  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.
thanks for your reply and the code - something like that would work with a few adjustments and one would need to take into account dimension labels and x-values being displayed in a table.
Still, a flag which does it would be nice to have.
Cheers
Christian
I modified the above code, this is what I came up with:

function reallyKillWaves(w)
   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  
Take a look at:

#include <Kill Waves>


Contains the following functions: KillAllWaves, RemoveWavesFromWindows, RemoveWavesFromWindow, RemoveWavesFromTable, RemoveWavesFromGraph and KillMatchingWaves.

WARNING: Routines in this file can kill wave files. Read the warnings and make sure you understand the routines before using them.


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.