Help with extending function to work on all open windows
epiphenom
Thanks in advance.
Function d()
String wnames =wavelist("*",";","WIN:") //WIN: means top graph
String name
Variable i
wave a
for(i =0;i < itemsinlist(wnames);i +=1)
name = stringfromlist(i,wnames)
print name
print rightx($name)
FindLevel /Edge=2 /Q/R =(2,10) $name ,-0.4; print V_LevelX;
FindLevel /Edge=2 /Q/R =(15,30) $name ,-0.4; print V_LevelX;
FindLevel /Edge=2 /Q/R =(31,50) $name ,-0.4; print V_LevelX;
endfor
End
String wnames =wavelist("*",";","WIN:") //WIN: means top graph
String name
Variable i
wave a
for(i =0;i < itemsinlist(wnames);i +=1)
name = stringfromlist(i,wnames)
print name
print rightx($name)
FindLevel /Edge=2 /Q/R =(2,10) $name ,-0.4; print V_LevelX;
FindLevel /Edge=2 /Q/R =(15,30) $name ,-0.4; print V_LevelX;
FindLevel /Edge=2 /Q/R =(31,50) $name ,-0.4; print V_LevelX;
endfor
End
The wavelist command can work on windows other than the top window by using the windowName.
"WIN:windowName" Consider all waves in the current data folder that are displayed in the named table or graph window or sub window.
To get the list of windowNames, you can use the WinList command with the specifier
"WIN:windowTypes " Consider windows that match windowTypes and graphs are type 1.
Andy
September 20, 2016 at 01:16 pm - Permalink
You can incorporate Andy's suggestion by enclosing your loop in a loop that goes through the windows, or you can add an argument to you function that takes the window name and then write a separate function that passes window names to your original function.
Instead of printing: a good solution is to make a textwave for your tracenames and then a numeric wave for the values, since you are pulling several values out this should be a 2D wave. Something like:
String wnames =wavelist("*",";","WIN:") //WIN: means top graph
String name
Variable i
//wave a //don't need this
Variable nWaves = itemsinlist(wnames)
Make/O/T/N=(nWaves) labelWave
Make/O/T/N=(nWaves,4) resultWave
for(i =0;i < nWaves;i +=1)
name = stringfromlist(i,wnames)
Wave w0 = $name
labelWave[i] = name
resultWave[i][0] = rightx(w0)
FindLevel /Edge=2 /Q/R =(2,10) w0 ,-0.4
resultWave[i][1] = V_LevelX
FindLevel /Edge=2 /Q/R =(15,30) w0 ,-0.4
resultWave[i][2] = V_LevelX
FindLevel /Edge=2 /Q/R =(31,50) w0 ,-0.4
resultWave[i][3] = V_LevelX
endfor
Edit labelWave,resultWave // show in a table
End
Warning: I've not tested that!
This will give your four values in each column, where each row is a wave in your window.
If you incorporate Andy's suggestion, you'll need to come up with a naming system for the labelWave and resultWave otherwise you'll just end up with the values for the last window the function processes.
Hope that helps
September 20, 2016 at 01:46 pm - Permalink
September 20, 2016 at 02:55 pm - Permalink