On Tue, Oct 15, 2002 at 10:59:22PM +1000, Stanley Hopcroft wrote:
> 
> CDEF:clipped=x,UpperBound,GT,UpperBound,x,IF,LowerBound,LT,LowerBound,x,IF
> 
> (the intent is that clipped is x:  LowerBound <= x <= UpperBound. I
> thought the CDEF would evaluate to
> min(x,UpperBound),LowerBound,LT,LowerBound,x,IF. Perhaps this is what I 
> should have done in the first place.)

This CDEF indeed does not work.  As always: mimic RRDtool and debug step
by step:


1:   x,UpperBound,GT      ---->  p
2:   p,UpperBound,x,IF    ---->  q
3:   q,LowerBound,LT      ---->  r
4:   r,LowerBound,x,IF    ---->  result of CDEF

In (1,2) you return min(x,UpperBound).  That's what you need.
In (3,4) you check the result of (1,2) agains LowerBound but return
either LowerBound (good) or x (bad).

Look at step (4): if (r) return LowerBound else return x
The value of 'r' is: q<LowerBound (true or false).
So, "if min(x,UpperBound) < LowerBound then return LowerBound else return x".

You need to replace 'x' in (4) with the result of (1,2).  This can be
done by just doing the calculation again, or you can do this by carefully
using DUP maybe together with EXC and/or POP.

HTH
Alex

--
Unsubscribe mailto:[EMAIL PROTECTED]
Help        mailto:[EMAIL PROTECTED]
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

Reply via email to