On Apr 10, 2006, at 10:11 PM, Tariel Gogoberidze wrote:

On Apr 9, 2006, at 1:00 PM, Geoff Canyon wrote:

Here is an example of something slightly larger than a single line
(and actually useful) that I think is bug-free:


on stableSetSize pID,W,H
   -- sets the width and height of pID
   -- while keeping the topleft the same
   try
     put the rect of pID into tRect
   catch tSomeError
     exit stableSetSize
   end try
   if W is a number then put item 1 of tRect + W into item 3 of tRect
   if H is a number then put item 2 of tRect + H into item 4 of tRect
   set the rect of pID to tRect
end stableSetSize


Assuming correct input  it seems to be bug free. However..

on mouseUp
  put "button 1" into PID
  put 500000000000000.2 into W -- !
  put 50.3 into H
  stableSetSize pID,W,H
end mouseUp

Throws execution error here "rectangle does not have 4 points"

:)

In discussion with a non-Rev-using friend earlier today (what, you don't spend your spare time discussing esoteric issues with your friends?) the idea of overflow was pointed out to me.

Note in my defense that the code is proof against non-integers, non- numbers, and negative numbers. So the only thing that should break it is too-large numbers.

That said, I noticed in the docs that if the lockLoc of an object is true, it resizes from the topleft. I thought this would be a good thing, but it means that I have to lock the screen in order to not show first the width changing, then the height. It also doesn't handle cds or groups, etc. So I stuck with the rectangle routine, but with more data checks:

on stableSetSize pID,W,H
  -- sets the width of and height of pID
  -- while keeping the topleft the same
  try
    put the rect of pID into tRect
  catch tSomeErr
    exit stableSetSize
  end try
  if W is a number then
    if word 1 of pID is among the items of "image,img" and \
        the platform is "MacOS" then
      put min(4096,W) into W  -- this is a temp
    end if
    put min(32767,W + item 1 of tRect) into item 3 of tRect
  end if
if H is a number then put min(32767,H + item 2 of tRect) into item 4 of tRect
  set the rect of pID to tRect
end stableSetSize

Maybe that will hold up a bit longer.

regards,

gc
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
  • Re: bugs Geoff Canyon

Reply via email to