[Thread Prev][Thread Next][Index]

[ferret_users] Re: whether break statement is available in ferret ?



Hi,
If you are using REPEAT loops in Ferret, you can use EXIT/LOOP.  So it might look like
yes? let istart = myvar[i=@LOC:1111]

yes? repeat/i=`istart`:`myvar,return=isize` (\
 def sym ii = `i`; IF `myvar[i=($ii)] eq 999` then exit/loop; \
 list/nohead myvar[i=($ii)] )
but loops are not the best way to make use of Ferret. The more ferret-like way to do this would be to define a mask variable and then do your operations on variables with the mask applied rather than a loop.
yes? let istart = myvar[i=@LOC:1111]
yes? let iend = myvar[i=@loc:999]

yes? let ii = i[gx=myvar]
yes? let mask = if ii ge istart and ii le iend then 1+0*myvar
and then do your computations on variables multiplied by mask.



On 3/15/2013 11:11 AM, Akshay Hegde wrote:
HI All !

I want to do some calculation in ferret, which I have already done
using IF ELSE, FOR LOOP, and BREAK Statements in C,
it is some thing like this, let me take one example here

myvar={1000,1111,1333,1444,1555,1666,999,888,333,222,111 }

here I want to list out only 1111,1333,1444,1555,1666

If break statement is available in ferret, I think it's possible by
taking starting increment value(1111) index and ending value(999)
index, by putting in loop and listing.


Thanks in advance,


Akshay


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement