[Thread Prev][Thread Next][Index]
Re: counting number of elements in a string array??
Hi Emilie, James & Ansley,
There is an easy fix for the problem paused
using any one of the functions XSEQUENCE, YSEQUENCE, ZSEQUENCE or
TSEQUENCE. Once the variable is sampled using this function, it will have
the "exact" size along the abstract axis corresponding to the function
used.
As a comment : If we know that there are files in the directory with
the given pattern (atleast one) then there is no
need to give the "dummy" along with the spawn
(see the example below).
NOAA/PMEL TMAP
FERRET v5.50
Linux 2.4.3-12smp - 01/15/03
14-Sep-04 22:46
yes? let fnames = {spawn: "ls *.nc"}
yes? list fnames
VARIABLE : {SPAWN: "ls *.nc"}
SUBSET : 3 points (X)
1 / 1:"gpcc.nc"
2 / 2:"junk1.nc"
3 / 3:"junk.nc"
yes? list `fnames,r=iend`
!-> list 2000
VARIABLE : constant
2000.
yes? list `fnames,r=istart`
!-> list 1
VARIABLE : constant
1.000
yes? let files = XSEQUENCE(fnames)
yes? list `files,r=iend`
!-> list 3
VARIABLE : constant
3.000
yes? let files = YSEQUENCE(fnames)
yes? list `files,r=jend`
!-> list 3
VARIABLE : constant
3.000
yes? let files = TSEQUENCE(fnames)
yes? list `files,r=lend`
!-> list 3
VARIABLE : constant
3.000
yes?
Hope this helps
Jaison
On Tue, 14 Sep 2004, Ansley Manke wrote:
> Hi Emile and James,
> Yes, this is a known bug with the spawn command. Thank you for the
> workaround, James.
>
> Ansley Manke
>
> James Orr wrote:
>
> >Emilie,
> >
> >You followed what was in the manual, and you are right: it does NOT
> >work. On the other hand it would work if you only listed the files
> >without using the spawn command, e.g.,
> >
> > let my_files = {"dummy", "box.dat", "boxmar.dat", "dummy"}
> >
> >A work around (while using the spawn command) would be to do the
> >following
> >
> > let my_files = {"dummy", spawn: "ls box*.dat", "dummy"}
> > let len_files = strlen(my_files)
> > let one_files = if len_files gt 0 then 1
> > let n = one_files[i=@sum]
> > list n
> >
> >-- Jim
> >
> >On Tue, 14 Sep 2004, Emilie Vanvyve wrote:
> >
> >
> >
> >>Hello,
> >>
> >>I have a little problem when I do the following to count the number of
> >>elements I have in a string array:
> >>
> >>yes? spawn ls
> >>box.dat plot-xy-hlat.jnl plot-xy-ro.jnl
> >>plot-xy.set-mask.jnl
> >>boxmar.dat plot-xy-precp.jnl plot-xy-t2m.jnl
> >>plot-xy.set-shakey.jnl
> >>yes?
> >>yes? let my_files = {"dummy", spawn: "ls box*.dat", "dummy"}
> >>yes? list my_files
> >> VARIABLE : {"dummy", SPAWN: "ls box*.dat", "dummy"}
> >> SUBSET : 4 points (X)
> >> 1 / 1:"dummy"
> >> 2 / 2:"box.dat"
> >> 3 / 3:"boxmar.dat"
> >> 4 / 4:"dummy"
> >>yes?
> >>yes? let n = `my_files,return=iend`
> >> !-> DEFINE VARIABLE n = 2002
> >>yes? let n = `my_files,return=jend`
> >> !-> DEFINE VARIABLE n = 0
> >>yes? let n = `my_files,return=kend`
> >> !-> DEFINE VARIABLE n = 0
> >>yes? let n = `my_files,return=lend`
> >> !-> DEFINE VARIABLE n = 0
> >>yes?
> >>
> >>Why is it so? Why do I not get n=4?
> >>I'm likely to have done just a stupid mistake somewhere, but I don't
> >>see.
> >>
> >>Emilie
> >>
> >>
> >>
> >>
> >>____________________________________________________________
> >>Emilie VANVYVE
> >>Physicist, PhD student
> >>
> >>Université catholique de Louvain (UCL)
> >>Institut d'astronomie et de géophysique G. Lemaître (ASTR)
> >>Chemin du Cyclotron, 2
> >>1348 Louvain-la-Neuve (Belgium)
> >>Phone : +32-(0)10-473300
> >>Fax : +32-(0)10-474722
> >>E-mail : vanvyve@astr.ucl.ac.be
> >>Web : www.astr.ucl.ac.be
> >>
> >>
> >
> >
> >
>
--
___________________________________________________
Jaison Kurian
Centre for Atmospheric and Oceanic Sciences
Indian Institute of Science
B A N G A L O R E 560 012
Ph: +91-80-3942505
+91-80-3600450
Fax:+91-80-3600865
___________________________________________________
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement