Strange pattr behavior with JS

Jul 27, 2010 at 9:38pm

Strange pattr behavior with JS

I’m struggling with strange pattr behavior. It seems to me that it is common for both JS and visual environment.
I use pattr to store param value between sessions. I need pattr to load param and trigger JS init method. If param is equal to 0 (it wasn’t initialized earlier) then its value is initialized and saved to pattr. Otherwise pattr value is used
As you can see, pattr triggers initVar method, but method fails to set pattr new value. When bang triggers initVar then all is fine
What can it be? A sort of loopback protection?

autowatch = 1;
inlets = 1;
outlets = 1;

var data;

function initVar(variable) {
data = parseInt(variable);
if (data == 0) {
data = 30;
post(“data ” + data);

– Pasted Max Patch, click to expand. –


  1. screenshot.jpg
Jul 27, 2010 at 10:56pm

Yeah, I imagine there could be a feedback problem there.

This works.

– Pasted Max Patch, click to expand. –
Jul 28, 2010 at 12:22pm

Awesome, thank you!


You must be logged in to reply to this topic.