problem sending out messages from [js]...

andrewj's icon

Hi,

I'm having a funny problem sending a message out of a [js] object. I want to send out the message:

getpixel 0 1

but the object sends

"getpixel 0 1"

which isn't liked by the [lcd] object I've plugged it into.

Here's the [js] code I'm using; if you'd like to see the rest of the max patch I can upload that too (I'm guessing the problem can be solved somehow in the [js] object)

//////////////////////
//imgRead.js
//////////////////////

inlets = 1;
outlets = 1;

var xx = 0;
var yy = 0;

var imgWidth = 0;
var imgHeight = 0;

function bang()
{
    if(xx == imgWidth)
    {
        xx = 0;
        yy += 1;
    }
    else
    {
        xx += 1;
    }

    //send:
    //getpixel x y
    //to the [lcd] object

    //problem: I'm getting "getpixel x y" in doublequotes.

    var message = 'getpixel ' + xx + ' ' + yy;
    outlet(0, message);
}

function size(width, height)
{
    //configure the width and height of the image

    imgWidth = width;
    imgHeight = height;
    //post(width + ', ' + height);
}

//////////////////////

Chris Muir's icon

Put a "fromsymbol" object after your javascript object.

-C

Chris Muir
cbm@well.com    
http://www.xfade.com

barry threw's icon

Its not that funny...thats the message you are sending...

Plus signs do not make a list, the concatenate.

Here:

outlet(0, 'getpixel', xx, yy);

bt

On May 25, 2008, at 8:00 PM, Andrew wrote:

>
> Hi,
>
> I'm having a funny problem sending a message out of a [js] object.
> I want to send out the message:
>
> getpixel 0 1
>
> but the object sends
>
> "getpixel 0 1"
>
> which isn't liked by the [lcd] object I've plugged it into.
>
> Here's the [js] code I'm using; if you'd like to see the rest of the
> max patch I can upload that too (I'm guessing the problem can be
> solved somehow in the [js] object)
>
> //////////////////////
> //imgRead.js
> //////////////////////
>
> inlets = 1;
> outlets = 1;
>
> var xx = 0;
> var yy = 0;
>
> var imgWidth = 0;
> var imgHeight = 0;
>
> function bang()
> {
>     if(xx == imgWidth)
>     {
>         xx = 0;
>         yy += 1;
>     }
>     else
>     {
>         xx += 1;
>     }
>
>     //send:
>     //getpixel x y
>     //to the [lcd] object
>
>     //problem: I'm getting "getpixel x y" in doublequotes.
>
>     var message = 'getpixel ' + xx + ' ' + yy;
>     outlet(0, message);
> }
>
> function size(width, height)
> {
>     //configure the width and height of the image
>
>     imgWidth = width;
>     imgHeight = height;
>     //post(width + ', ' + height);
> }
>
> //////////////////////
>

andrewj's icon

> outlet(0, 'getpixel', xx, yy);

That worked. Thanks for your patience, guys. No matter how noobish my questions are, you're always there for me. :)

I intend to post the patch as soon as I finish. It probably won't be the most amazing Max patch ever, but I think it's kind of a cool idea...