Re: integers from a string

From: Adam Phillips (asphilli AT cgd.ucar.edu)
Date: Wed Sep 21 2005 - 15:44:37 MDT


Hi Colleen,

I would suggest using the stringtochar function, which places each
individual letter/number/etc into an array. Then grab the specific
character (=integer) you want, and pass it back thru chartostring and
stringtointeger:

ts = "Testing 1-2"
a = stringtochar(ts)
print(a)
val1 = stringtointeger(chartostring(a(8)))
val2 = stringtointeger(chartostring(a(10)))

This will work assuming that the locations of the integers doesn't
change from string to string if you are reading multiple strings.

Adam

Colleen Henry wrote:
> I have a string that contains two integers, and ultimately I want to be
> able to read them into separate variables or into a two-dimensional
> array. I've tried the "stringtointeger" function, but that only captures
> the first value. Are there any other options besides this function?
>
>
> ********************
> Colleen Henry
> Graduate Student
> Department of Earth and Atmospheric Sciences
> 550 Stadium Mall Dr.
> Purdue University
> West Lafayette, IN 47906
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk AT ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli AT ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk AT ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Fri Sep 23 2005 - 14:29:36 MDT