Comparing two forms

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Comparing two forms

Sean P. DeNigris
Administrator
How do you compare two forms to see if they are the same image?

I did: form1 bits should equal: form2 bits.  Is there a better way?

Thanks.
Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Comparing two forms

Jerome Peace
Hi Sean,

Hmmm. I'd like to compare two forms by saying

form1 = form2 .

Unfortunately nobody has defined a suitable = for Form.
It inherits from Object and Object treats = like ==

so form1 = form1 copy ---> false!

If there were an =, I would want it to check
height width and depth for equality before checking the bits.
Usually things won't match and that would save a lot of time.

Then I would like some good way to hash the bits into a useful static number. Do that once each time the bits change. Hold on to it and compare the hashes before comparing the bits.

Your way is not bad if you include the other h w and d .

Oh and you have to make sure that both forms are in an equal state of hibernation.

The fact that = doesn't work probably means no one actually compares forms directly.

====
Try two.
Assuming you have two forms equal in h d and w
you could combine them using a subtracting rule. I think there is a quick check for allWhite. I don't know if it works other than at depth one.

===

Maybe someone else will have come accross this problem for real.

Yours in curiosity and service, --Jerome Peace





--- On Fri, 4/30/10, Sean P. DeNigris <[hidden email]> wrote:

> From: Sean P. DeNigris <[hidden email]>
> Subject: [Newbies] Comparing two forms
> To: [hidden email]
> Date: Friday, April 30, 2010, 11:53 PM
>
> How do you compare two forms to see if they are the same
> image?
>
> I did: form1 bits should equal: form2 bits.  Is there
> a better way?
>
> Thanks.
> Sean




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners