Page 1 of 1

assigning a .x value to a list.

Posted: 20 Jun 2012 02:11
by fhill2
Is it possible assign 4 separate switches to - switch1.x==switch[0].... switch2.x==switch[1].... etc. Where switch is an incoming OSC packet of 0 0 1 0 or any combination?
How would I correctly set this up? :oops:
Thanks

Re: assigning a .x value to a list.

Posted: 20 Jun 2012 06:14
by highmountain
You need to add a script somewhere. Select it and change the execution to "On Osc". Set a custom address if you want. Then in the script you want to do this:

switch1.x = OSC_ARGS[0];
switch2.x = OSC_ARGS[1];
switch3.x = OSC_ARGS[2];

and so on.

Re: assigning a .x value to a list.

Posted: 20 Jun 2012 07:26
by fhill2
Thanks for the reply highmountain, it helped me a lot!
:P

Re: assigning a .x value to a list.

Posted: 22 Jun 2012 09:46
by fhill2
For setting attributes, will it be the same?
I have tried: setattribute(textitem1,content,OSC_ARG[0]);

Going further, how would I make a loop statement to assign each item in the OSC arguments to each of the 16 text object's contents I have(in ascending order).
I have been messing about with lots of code, but nothing compiles correctly.!! :o
Thanks

Re: assigning a .x value to a list.

Posted: 22 Jun 2012 15:39
by bxsj
You should read the manual regarding "arrays" and "vectors".
B.

PS.: setattribute(textitem1,content,{OSC_ARG[0], OSC_ARG[1], ... });

Re: assigning a .x value to a list.

Posted: 22 Jun 2012 23:36
by fhill2
Ah, for newbies like me. Don't forget the single quotation's at the start and end of the attribute's content. :oops:
for example.
CORRECT: setattribute(pl0,'content',OSC_ARGS[0]);
INNCORRECT: setattribute(pl0,content,OSC_ARGS[0]);

Re: assigning a .x value to a list.

Posted: 23 Jun 2012 00:03
by fhill2
This is my best attempt to assign each item in the OSC arguments to each of the 16 text object's contents I have(in ascending order):

decl i;
for(i=0; i<16;i++);
{
setattribute(textitem,'content',OSC_ARGS));
}

This doesn't compile, can anyone help?
Thanks.

Re: assigning a .x value to a list.

Posted: 23 Jun 2012 15:04
by bxsj
If "textitem" is a text object, the setattribute command has to be called separately for each text object:

setattribute(textitem1,'content',OSC_ARGS[1]);
setattribute(textitem2,'content',OSC_ARGS[2]);
and so on ...

Just another hint: A switch object can have multiple columns (and rows). So for a switch object with 5 columns, the x value of the switch is an array containing the 5 x values for each column...

Hope that helps,
BxSj

Re: assigning a .x value to a list.

Posted: 25 Jun 2012 16:20
by axel_liine
fhill2 wrote:This is my best attempt to assign each item in the OSC arguments to each of the 16 text object's contents I have(in ascending order):

decl i;
for(i=0; i<16;i++);
{
setattribute(textitem,'content',OSC_ARGS));
}

This doesn't compile, can anyone help?
Thanks.

I see an extra parenthesis at the end of the line ')'