
Expand A Numerical Input Range to All Values

jjweimer
The function illustrates both the use of an optional input and grep pattern matching in SplitString.
Example
ExpandString("9-12",sep="..") will return 9..10..11..12..
Function/S ExpandString(theStr, [sep]) string theStr, sep string xs, xe variable ns, ne, ic if(ParamIsDefault(sep)) sep = "," endif SplitString/E="(.+)-(.+)" theStr, xs,xe if (strlen(xs)==0) return (theStr + sep) endif ns = str2num(xs) ne = str2num(xe) theStr = "" for(ic=ns;ic<(ne+1);ic+=1) theStr += num2str(ic) + sep endfor return theStr end

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More