Convert text wave into numeric wave and vice versa

// Handy Function to convert numeric waves into text waves
Function ConvertNumWvToTxtWv(W)
Wave W
Variable np = numpnts(W)
Make /T /O /N=(np) TxtConvert
Variable x
for(x=0;x<np;x+=1)
    TxtConvert[x] = num2str(W[x])
endfor
End
 
// Handy Function to convert text waves into numeric waves
Function ConvertTxtWvToNumWv(W)
Wave /T W
Variable np = numpnts(W)
Make /O /N=(np) NumConvert
Variable x
for(x=0;x<np;x+=1)
    NumConvert[x] = str2num(W[x])
endfor
End
How about using a wave assignment instead of a loop?
Function ConvertNumWvToTxtWv(W)
Wave W
 
Make /T /O /N=(numpnts(W)) TxtConvert
TxtConvert[] = num2str(W[p])
endfor
End
 
Function ConvertTxtWvToNumWv(W)
Wave /T W
 
Make /O /N=(numpnts(W)) NumConvert
NumConvert[] = str2num(W[p])
End

We don't need a function: 

Make /T /O /N = (numpnts(W)) TxtConvert = num2str(W[p])
 
Make /O /N = (numpnts(W)) NumConvert = str2num(W[p])

 

Note that this is generally not such a good idea, since there is the possibility to loose precision on the way (especially when using num2str()). See:

Make/D/O test = e^p
•print/D test[100]
  2.688117141816125e+43
•Make/T/O/N = (numpnts(test)) TxtC = num2str(test[p])Make/D/O/N = (numpnts(TxtC)) NumC = str2num(TxtC[p])print/D NumC[100]
  2.6881e+43

You would at least want to control the precision, which can be done from Igor 9 onward using an optional formatStr.

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More