[Thread Prev][Thread Next][Index]
Re: How to do loop in ferret?
Hi Xin,
You can use an approach like
let name = {"a","b","c","d"}
repeat/i=1:4 GO sub_scrib name[i=`i`]
This passes the string (e.g.) "name[i=2]" to sub_scrib. To pass the
*value*
you could use the more elaborate approach
repeat/i=1:4 (define symbol ii `i`; GO sub_scrib `name[i=($ii)]`)
You can test this quickly using the SAY alias
repeat/i=1:4 (define symbol ii `i`;SAY `name[i=($ii)]`)
- steve
=========================
Xin Jin wrote:
> Hi Ferreters,
>
> I have a question about how to do loop in ferret. For example:
>
> I have defined four regions and assigned them to a string array,
> Name[i=1:4] and I want to do the same things in each region. But How
> to do it?
>
> It seems I cannot use repeat command to do it.
>
> repeat/i=1:4 (go sub_scrib Name).
>
>
> Howhever I can do it one by one as
>
> go sub_scrib Name[i=1]
> go sub_scrib Name[i=2]
> go sub_scrib Name[i=3]
> go sub_scrib Name[i=4]
>
> Thanks
>
> Xin
>
> ________________________________________
>
> Xin Jin
> Inst.of Geophysics and Planetary Physics
> University of California Los Angeles
> 5845 Slichter Hall
> Los Angeles, CA 90095-4996, USA
> phone: (310) 825 4526
> fax : (310) 206 3051
> email: xjin@igpp.ucla.edu
>
>
--
| NOAA/PMEL | ph. (206) 526-6080
Steve Hankin | 7600 Sand Point Way NE | FAX (206) 526-6744
| Seattle, WA 98115-0070 | hankin@pmel.noaa.gov
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement