[javascript-dev] [sharingisfun] passing messages via pattrstorage
pnyboer
pnyboer at slambassador.com
Tue Sep 25 14:19:24 MDT 2007
- Previous message: [javascript-dev] Re: controller/lfo mapping slider
- Next message: [javascript-dev] [sharingisfun] passing messages via pattrstorage
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I've long been craving a way to pass messages via pattrstorage to other parts of the patch. I finally realized a way to do it!
For example if you have a pattrstorage with greedy on, and you want to pass some subpatch a "bang" message, I've had to rely on named number boxes and a "sel" or "t" object to convert the integer into a bang. So if I want to send the message:
MovieModule::Reverse bang
into pattrstorage and have it received in the MovieModule, I can do that with this small javascript:
/*
used to pass symbols (or anything else) to patches that are pattr-ized. name the js object that hosts this with a scripting name (such as "jim") then you can send messages like "Patch::SubPatch::jim hello" to the patch that contains this.
js by Peter Nyboer pnyboer at slambassador dot com
*/
//begin "getset.js"
autowatch = 1;
var thevalue = "none";
var thevalue_ = "none";
function getvalueof() {
return thevalue;
}
function setvalueof(v) {
thevalue= v;
if(thevalue != thevalue_) {
outlet(0,thevalue);
//post("SET",thevalue);
}
thevalue_ = thevalue;
}
function setthevalue(v){
thevalue= v;
thevalue_ = thevalue;
notifyclients();
}
//end "getset.js"
//begin "getset.help"
#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P comment 33 148 211 196617 used for storing a symbol or arbitrary value for pattr;
#P window linecount 1;
#P newex 31 109 47 196617 print ??;
#P newex 198 88 32 196617 print;
#P objectname p[1];
#P message 195 44 73 196617 something jim;
#P message 71 32 31 196617 hello;
#P message 31 32 34 196617 jones;
#P newex 31 58 100 196617 prepend setthevalue;
#P newex 198 115 60 196617 autopattr q;
#X prestore something 1 0 jim;
#P objectname q;
#P newex 198 65 75 196617 pattrstorage p;
#X client_rect 288 399 661 627;
#X storage_rect 0 0 640 240;
#P objectname p;
#P newex 31 79 62 196617 js getset.js;
#P objectname something;
#P comment 96 80 100 196617 named "something";
#P connect 7 0 2 0;
#P connect 1 0 9 0;
#P connect 4 0 1 0;
#P connect 6 0 4 0;
#P connect 5 0 4 0;
#P window clipboard copycount 11;
//end "getset.help"
--
* * * *
The Altamont
2 oz light rum
3/4 oz lime juice
1/2 oz orange curaçao
1/4 oz orgeat
splash of pernod
handful of fresh mint leaves
shake contents vigorously with ice.
Strain well into a chilled cocktail glass.
* * * *
- Previous message: [javascript-dev] Re: controller/lfo mapping slider
- Next message: [javascript-dev] [sharingisfun] passing messages via pattrstorage
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
