Javascript documentation.
The see also section of the javascript tutorials do not point to the
other tutorials, and I haven't found any link to a javascript reference
for max 5 anywhere.
I wanted to find out about the patcher method "newobject" for scripting,
and unfortunately the example in the old JavascriptInMax pdf has an
example which doesn't help too much...
The tutorial 2 creates ctlins which are too big, but how to create them
with a proper width? It points to the newobject method, but I can't find
any reference how to use it in Max 5...
But (not) learning the patcher methods by trial and error isn't too much
fun... I usually come along well with examples I can modify...
Stefan
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com
On 20 mai 08, at 08:42, Stefan Tiedje wrote:
> I wanted to find out about the patcher method "newobject" for
> scripting, and unfortunately the example in the old JavascriptInMax
> pdf has an example which doesn't help too much...
You can use the send message. Then the syntax will be the same as the
one demonstrate in the "Making new objects" subpatcher of the
thispatcher help file. For instance:
this.patcher.message("script", "newobject", "comment",
"@varname", i + "_unitlabel",
"@presentation_rect", 280, y, 130, 20,
"@patching_rect", 280, y, 130, 20,
"@presentation", 1,
"@text", ppList[i].unit,
"@fixwidth", 1
);
ej
Emmanuel Jourdan schrieb:
> You can use the send message. Then the syntax will be the same as the
> one demonstrate in the "Making new objects" subpatcher of the
> thispatcher help file. For instance:
I tried this for instance:
this.patcher.message("script", "newobject", "newobj",
"@varname", "ctlobj[" + k + "]",
"@patching_rect", 250+k*30, 50, 280+k*30, 70,
"@text", ctlin, k+1
);
And it complained:
js: autosurface.js: Javascript ReferenceError: ctlin is not defined...
...
The js reference claims: "Any message to a patcher that you can send in
Max (via the thispatcher object) you can send in Javascript in js."
How do I send the size message: "script size var1 100 15" like in the
example to thispatcher?
I tried
this.patcher.size(controlin[k], 27, 15);
but it didn't work. Maybe because the the object doesn't have a
scripting name yet...
I go through this, because I want to see if scripting within javascript
is easier than with thispatcher, but it seems much more complicated... ;-)
Stefan
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com
On 20 mai 08, at 11:04, Stefan Tiedje wrote:
> Emmanuel Jourdan schrieb:
>> You can use the send message. Then the syntax will be the same as
>> the one demonstrate in the "Making new objects" subpatcher of the
>> thispatcher help file. For instance:
>
> I tried this for instance:
>
> this.patcher.message("script", "newobject", "newobj",
> "@varname", "ctlobj[" + k + "]",
> "@patching_rect", 250+k*30, 50, 280+k*30, 70,
> "@text", ctlin, k+1
> );
>
> And it complained:
>
> js: autosurface.js: Javascript ReferenceError: ctlin is not defined...
it should proabably be:
"@text", "ctlin " + k+1
> The js reference claims: "Any message to a patcher that you can send
> in Max (via the thispatcher object) you can send in Javascript in js."
>
> How do I send the size message: "script size var1 100 15" like in
> the example to thispatcher?
>
> I tried
>
> this.patcher.size(controlin[k], 27, 15);
>
> but it didn't work. Maybe because the the object doesn't have a
> scripting name yet...
Then you need to name it:
controlin[k].varname = "ctrlin_" + k;
this.patcher.message("script", "size", "ctrlin_" + k, 100, 15);
You should also be able to use the rect property of a MaxObject.
ej
Emmanuel Jourdan schrieb:
> it should proabably be:
>
> "@text", "ctlin " + k+1
Thanks, that did the trick (after I put (k+1) in brackets). Does that
mean that these attributes have a fixed number of arguments? and @text
will only take one single argument?
Or is there an alternative notation also possible...
I never know when I have to combine things with "+" or when I have to
separate them with a comma. In Max I don't have to care about this but
js is picky... ;-)
Stefan
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com
On 20 mai 08, at 15:42, Stefan Tiedje wrote:
> Thanks, that did the trick (after I put (k+1) in brackets). Does
> that mean that these attributes have a fixed number of arguments?
> and @text will only take one single argument?
> Or is there an alternative notation also possible...
It depends on the attribute. For instance bordercolor would take 4
floats, here text takes only one string. You can find that easily by
"looking at the object as text" (copy of the object, paste in a text
file).
ej