Bug in setting setting the height of rectangles

Jim Hurley jhurley at infostations.com
Tue Jan 13 10:47:04 EST 2004


>
>Jim Hurley wrote:
>
>>  I have been getting some strange results setting the heights of
>>  graphic rectangles--programmatically.
>>
>>  For example the following run from the msg box:
>>
>>  put the height of grc 1 & return after results
>>  set the height of grc 1 to (the height of grc 1) + 0.1
>>  put the height of grc 1 after results
>>  put results
>>
>>  Gives:
>>
>>  70
>>  70
>>
>>  As it should. The addition of .1  to the height should have no
>>  effect. Graphic 1 is a rectangle.
>>
>>  But
>>
>>  put the height of grc 1 & return after results
>>  set the height of grc 1 to (the height of grc 1) - 0.1
>>  put the height of grc 1 after results
>>  put results
>>
>>  Gives:
>>
>>  70
>>  69
>>
>>  Whereas it should give
>>
>>  70
>>  70
>>
>>  Subtracting .0000001 from the height also gives
>>
>>  70
>>  69
>>
>>  (The +.1 and -.1 arise from a variable determined from a calculation.)
>>
>>  Mac OS 9, RR 2.1.2
>>
>>  If anyone can confirm this, I will Bugzilla it.


Richard Gaskin wrote:

>Is it a bug if it's rounding the subtraction to the nearest whole pixel?
>Would round(0.00001) give you what you're looking for?
>
>


Richard,

You're right. Rounding would work.

The problem is that it would be preferable if the engine would treat 
-.0001 and +.0001 in a consistent way.

My original code looked something like this:

     set the height of grc 1 to the height of grc 1 + someIncrement

using "someIncrement" to increase the graphic height. Unfortunately, 
someIncrement took on some unexpected small, negative numbers.

I have since revised the code so that the graphic height is stored in 
a variable (myGraphicHeight) which is then incremented with 
someIncrement. The graphic height is then set to myGraphicHeight, 
thus avoiding the quirk in RR--myGraphicHeight is always large and 
positive.

This same behavior applies to fields as well:

      set the height of field 1 to the height of field  1 + someIncrement

works as expected if someIncrement is +.000001 but decreases the 
pixel height of the field by 1 pixel if someIncrement is -.000001. As 
you say, the work-around is to round "someIncrement".

Jim


More information about the use-livecode mailing list