
String list to wave labels

ChrLie
// this snippet takes a semicolon separated list and writes each element as dimension label in the required dimension. //Example: //Make/N=(2,3) M_w //List2WaveLabels(M_w, "aa;bb;cc", 1) //edit M_w.ld function List2WaveLabels(w, str, dim) wave/Z w string str variable dim // e.g. 0 for rows, 1 for colums variable nPnts = DimSize(w, dim) if (ItemsInList(str) != nPnts) printf "Error: Dimension %g of wave %s has %g entries but the string has %g.", dim, NameOfWave(w), nPnts, ItemsinList(str) return -1 endif variable i = 0 for(i=0; i<nPnts; i+=1) SetDimLabel dim, i, $StringfromList(i, str), w endfor return 1 end

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
Minor nit:
I would either use
Wave w
in the parameter declaration, or useWave/Z w
and later check for existence withJanuary 22, 2015 at 02:58 am - Permalink