[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Chopping up a string
"Noam R. Izenberg" <noam.izenberg@jhuapl.edu> writes:
> I have a set of 5 numbers in a string seprated by spaces
> (e.g.string= '0 1 2 3 4'), and i need to chop them into seperate
> integer variables (var1=0, var2=1 etc...) I would use the various
> strmid commends exept the size of the numbers is not always the
> same. Sometimes one or more of the numbers will be 2 or more
> digits. (e.g. '14 14 256 5 2').
IDL> string= '0 1 2 3 4'
IDL> vars = long(str_sep(strcompress(string),' '))
IDL> help, vars
VARS LONG = Array[5]
IDL> print, vars
The STRCOMPRESS is optional if you can guarantee a single space
between numbers.
Craig
--
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------