Keeping a message intact going through cycle?
Hey everyone,
I've run into an issue with the cycle object (not cycle~). I want to send a "bgcolor x x x x" message through it to color certain parts of my gui but the cycle object cuts the message and sends "bgcolor" and then each of the numbers out seperately. If I add quotations then it'll keep the whole thing together but the objects receiving the object can't parse it. Am I just going to have to suck it up and use stacks and stacks of separate message boxes? Cycle seems like it would have been such a nice, clean solution :/
Have a look at [tosymbol] and [fromsymbol] which will combine messages into a single string and then split them out again.
or build your own cycle patch using [counter] and [gate]
Also the jit.cycle object leaves lists intact. If I recall, it's basically the same code as rotator.
Best, Jeremy
Here's a javascript that will (hopefully) do what you want:
// lh.cycle.js
outlets = jsarguments[1];
var mode = (jsarguments[2]>0);
var t = new Task(timer);
var i = 0;
function anything() {
if (mode) {
if (t.running) {
t.cancel();
}
t.schedule(100);
}
outlet(i++ % jsarguments[1],arrayfromargs(messagename,arguments));
}
function timer() {
i = 0;
}
function set(x) {
i = Math.min(Math.max(x,0),jsarguments[1] - 1);
}
function thresh(x) {
mode = x;
}
autowatch = 1;
//EOF
Thank you everyone! All of your responces were really helpful. I ended up going with a [route] based solution in the end, but I learnt a lot from your responces!