[Thread Prev][Thread Next][Index]
Re: counting number of elements in a string array??
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
--
======================================================================
James Orr
Laboratoire des Sciences du Climat et de l'Environnement
Unite Mixte de Recherche CEA-CNRS
LSCE, CEA Saclay http://www.ipsl.jussieu.fr/~jomce
Bat. 709 - Orme mailto: orr@cea.fr
F-91191 Gif-sur-Yvette Cedex Phone: (33) (0)1 69 08 77 23
FRANCE Fax: (33) (0)1 69 08 77 16
======================================================================
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement