XML Feeds

.

[javascript-dev] Re: [sharingisfun] js based change filter

keith manlove keithmanlove at gmail.com
Thu Sep 6 17:33:17 MDT 2007


Thanks a lot for both of these.  I've been learning javascript and
seeing examples like these really enlighten things for me.  Very
slick.  The use of arrayfromargs is especially nice.

Thanks again,
Keith

On 9/6/07, Emmanuel Jourdan <c74-mailinglists at e--j.com> wrote:
> On 6 sept. 07, at 23:17, Emmanuel Jourdan wrote:
>
> > anything allows you to receive any message. For example, if you
> > send an integer and the msg_int method is not defined, the anything
> > function will be triggered. This is espacially useful for symbols
> > as it's not possible to think about every symbol you could send.
>
> Maybe an example will make it clearer, to achieve the changeany you
> could have only use the anything method:
>
> var lastThing = new Array();
>
> function anything()
> {
>         var i;
>         var tmp = arrayfromargs(messagename, arguments);        // make an array
> from the message
>         var isDifferent = false;
>
>         if (lastThing.length == tmp.length) {
>                 for (i = 0; i < tmp.length; i++)
>                         if (lastThing[i] != tmp[i]) {
>                                 isDifferent = true;
>                                 break;
>                         }
>         } else
>                 isDifferent = true;
>
>         if (isDifferent) { // it has changed
>                 outlet(0, tmp);
>                 lastThing = arrayfromargs(messagename, arguments); // it's easier
> to call arrayfromargs again to make the copy of the array
>         }
> }
>
> ej
>
>
> _______________________________________________
> javascript-dev mailing list
> javascript-dev at cycling74.com
> http://www.cycling74.com/mailman/listinfo/javascript-dev
>


More information about the javascript-dev mailing list