numerically sort wave list
ali8
I have waves such as: wave001_411, wave002_411, ..., wave999_411. I want to sort the "Wave List".
I use:
#pragma rtGlobals=1 // Use modern global access method.
#include <WindowBrowser>
Function ali()
String Vx_list = WaveList("dVdI*_Vx_1011", ";", "")
Make/N=63 textwave
Variable nwaves = ItemsInList(Vx_list)
textwave=stringFromList(0,Vx_list)
Edit textwave
Sort textwave,textwave
print textwave
end
#include <WindowBrowser>
Function ali()
String Vx_list = WaveList("dVdI*_Vx_1011", ";", "")
Make/N=63 textwave
Variable nwaves = ItemsInList(Vx_list)
textwave=stringFromList(0,Vx_list)
Edit textwave
Sort textwave,textwave
print textwave
end
but I get an error, IGOR does not recognize stringFromList...And actually I am not sure if the above is what I need. All what I need is to sort Vx_list.
Is there any way to do this? i.e. to let IGOR sort based on the first number part in the file names?
#include <WindowBrowser>
Function ali()
String Vx_list = WaveList("dVdI*_Vx_1011", ";", "")
Variable nwaves = ItemsInList(Vx_list)
Make/O/N=(nwaves)/T textwave // you forgot the /T
textwave=stringFromList(p,Vx_list) // your version got only the first element from the list
Edit textwave
Sort textwave,textwave
print textwave
end
instead.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
August 13, 2013 at 05:05 pm - Permalink
Is this, anyway, I will need to convert the new text wave into a string. How to do that?
EDIT: Yes, /T solved the problem.
Now, how can I convert the text wave back to a String to use it in place of the unsorted list Vx_List ?
August 13, 2013 at 05:33 pm - Permalink
#include <WindowBrowser>
Function ali()
String Vx_list = WaveList("dVdI*_Vx_1011", ";", "")
Make/N=63 textwave
Variable nwaves = ItemsInList(Vx_list)
textwave=stringFromList(0,Vx_list)
Edit textwave
Sort textwave,textwave
String list= TextWaveToStringList(textwave)
print list
end
Function/S TextWaveToStringList(tw)
Wave/T tw
String list=""
Variable i, n= numpnts(tw)
for(i=0; i<n; i+=1 )
list += tw[i]+";"
endfor
return list
End
HOWEVER, why not just use SortList on the original WaveList result?
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
August 13, 2013 at 09:42 pm - Permalink
August 14, 2013 at 06:16 am - Permalink