Extracting the state of a toggle in JavaScript

Eric Lyon's icon

Is there a message that can be sent to a Javascript-created toggle to learn its current state (which may have been altered by the user)?

TiA,
Eric

Emmanuel Jourdan's icon

Assuming that you have a toggle somewhere in the patcher named "yoyo". You can use the pattr system to get it's value using getvalueof.

function bang()
{
var toggle = this.patcher.getnamed("yoyo");
outlet(0, toggle.getvalueof());
}

Eric Lyon's icon

Outstanding. Thanks EJ!

hems's icon

the javascript documentation could be extended / improved a little bit more..

lets see what version 6 will bring to us!

any references / articles in this matter are always welcome!

happy patching guys!

hems's icon

duplicated, sorry

hems's icon

super cool, that was the little and important piece i was needing for my javascript toggle sequencer, i should post sources very soon ( :

tks guys!

hems's icon

the current version is attached.

yet super simple, build a grid of toggles than outputs bang when the playhead passes by a toggle set to ON.

need to improve it a bit to be really useful, but the main concept and code is pretty much there.

any feedbacks, suggestions, improvements, are more than welcome.

peace

2497.trigercreator.zip
zip