function str2number, strarr, quiet=quiet quiet=keyword_set(quiet) tarr=strlowcase(strarr) ; reduce search space bstring=byte(tarr) ; convert to bytes ; define search values b0=(byte('0'))(0) ; numbers b9=(byte('9'))(0) bd=(byte('.'))(0) ; special number characters "-" and "." bn=(byte('-'))(0) nonnumeric=where((bstring lt b0 or bstring gt b9) $ ; identify non-numerics and (bstring ne bd) and (bstring ne bn),ncnt) if ncnt gt 0 then bstring(nonnumeric)=32b ; blank them out numbers=strcompress(string(bstring),/remove) ; eliminate them ; print "no numeric" warning if applicable nchk=where(numbers eq '',ncnt) if ncnt gt 0 and not quiet then $ message,/info,"Some input contains no numeric data (set those to zero)" chkflt=where(strpos(numbers,'.') ne -1,fcnt) ; floating data? case 1 of fcnt gt 0: numbers = float(numbers) ; yes, output fltarr else: numbers=long(numbers) ; no, output lonarr endcase return,numbers end