Re: could I get the string "abc" from a string of "abc.dat" in NCL?

From: Mateus da Silva Teixeira <mtex2k3_at_nyahnyahspammersnyahnyah>
Date: Wed, 11 Apr 2007 13:03:10 -0300

Lin,

You can use stringtochar() and chartostring() functions. See an example:

> a="12345"
> b=stringtochar(a)
> print(b)

Variable: b
Type: character
Total Size: 6 bytes
6 values
Number of Dimensions: 1
Dimensions and sizes: [6]
Coordinates:
(0) 1
(1) 2
(2) 3
(3) 4
(4) 5
(5) 0x00

> c=chartostring(b(0:2))
> print(c)

Variable: c
Type: string
Total Size: 4 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 123

I hope it helps you!
Mateus

LEO_ARIES escreveu:
> hi,all
> I have a small question on the string manipulation in NCL.
> Here below is some of my script:
> all_files = systemfunc ("ls " + "*.dat")
> n = dimsizes(all_files)
> do i = 0,n-1
> x =asciiread(all_files(i),-1,"float")
> .....
> wks = gsn_open_wks("eps",all_files(i))
> res = True
> ......
> res_at_gsnLeftString <mailto:res_at_gsnLeftString> = all_files(i) ? Notice :
> here is the problem i want to resolve, the last 4 character of the
> string "all_files(i)"
> is ".dat", but I don't want them in the resource of "gsnLeftString".
> Could I have any solution to get all the other character except the
> ".dat" ?
> plot = .....
> end do
> end
> Thanks in advance
> Lin
>
> ------------------------------------------------------------------------
> LEO_ARIES
> 2007-03-27
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Apr 11 2007 - 10:03:10 MDT

This archive was generated by hypermail 2.2.0 : Tue Apr 17 2007 - 15:41:32 MDT