[Thread Prev][Thread Next][Index]

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



Hi Ansley,

I tried the second method but got the following error:

yes? let myvar={1000,1111,1333,1444,1555,1666,999,888,333,222,111}
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
yes? list myvar*mask
 **ERROR: dimensions improperly specified: 9999999 words were requested.
 *** NOTE: Check for unspecified limits on an ABSTRACT axis
 *** NOTE: Use the SHOW GRID command to see the axes

Am I missing some point?

For just listing, why not just issue this:
yes? list myvar[i=`istart`:`iend`]

Thanks,

Jagadish

From: Ansley Manke <ansley.b.manke@xxxxxxxx>
To: Akshay Hegde <akshay.k.hegde@xxxxxxxxx>
Cc: ferret_users@xxxxxxxx
Sent: Monday, March 18, 2013 5:50 PM
Subject: [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