Forums > MaxMSP

How to reference a pattr object in a parent patcher

August 24, 2007 | 4:26 pm

Hi all,

I’ve looked at the archives but didn’t find a solution :
How can I reference a pattr object situated in the parent patcher of a subpatcher?
I tried pattrhub @patcher parent::this or parent::this patcher but it doesn’t work, as in the patch below.
I for sure understand how to cummunicate between two sub_patcher but not a sub_patcher and his father.

thanks for your answers.

Bruno.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 432 215 48 196617 loadbang;
#P newex 257 280 61 196617 prepend set;
#P newex 169 280 61 196617 prepend set;
#P window linecount 0;
#P message 257 306 159 196617;
#P message 169 333 159 196617;
#P flonum 432 238 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 169 246 48 196617 pattrhub;
#P flonum 432 285 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 432 262 60 196617 pattr test2;
#X prestore 1 0 23.;
#P objectname test2;
#N vpatcher 625 509 1225 909;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 186 85 48 196617 gettest2;
#P flonum 56 73 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 56 102 49 196617 test2 $1;
#P newex 141 172 150 196617 pattrhub @patcher parent::this;
#P connect 2 0 1 0;
#P connect 3 0 0 0;
#P fasten 1 0 0 0 61 146 146 146;
#P pop;
#P newobj 174 182 40 196617 p child1;
#P connect 9 0 4 0;
#P connect 3 1 8 0;
#P connect 3 0 7 0;
#P connect 7 0 5 0;
#P connect 8 0 6 0;
#P connect 4 0 1 0;
#P connect 1 0 2 0;
#P window clipboard copycount 10;


August 24, 2007 | 4:37 pm

[edit] oups, this is the good patch :

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 432 215 48 196617 loadbang;
#P flonum 432 238 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 432 285 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 432 262 60 196617 pattr test2;
#X prestore 1 0 23.;
#P objectname test2;
#N vpatcher 266 495 866 895;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 226 215 61 196617 prepend set;
#P newex 138 215 61 196617 prepend set;
#P window linecount 0;
#P message 226 241 159 196617;
#P message 138 268 159 196617 gettest2;
#P window linecount 1;
#P message 186 85 48 196617 gettest2;
#P flonum 56 73 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 56 102 49 196617 test2 $1;
#P newex 141 172 150 196617 pattrhub @patcher parent::this;
#P connect 2 0 1 0;
#P connect 0 0 6 0;
#P connect 6 0 4 0;
#P connect 3 0 0 0;
#P fasten 1 0 0 0 61 146 146 146;
#P connect 0 1 7 0;
#P connect 7 0 5 0;
#P pop;
#P newobj 369 166 40 196617 p child1;
#P connect 4 0 3 0;
#P connect 3 0 1 0;
#P connect 1 0 2 0;
#P window clipboard copycount 5;



jln
August 24, 2007 | 7:02 pm


August 25, 2007 | 9:35 pm

> You can use the pattr’s bindto attribute, as below. Does this work
> for you ?

yes thanks ;-)
As I can also bang the pattr object to get the value, then it works for me.

But I have a strange behavior that I don’t understand :
Why #1 (argument) is properly replaced as in a "send #1_processor" object but not in an object like "pattr @bindto parent::#1_processor". Is it only a problem of having caracters (::) before #1 ?


August 26, 2007 | 2:08 am

> But I have a strange behavior that I don’t understand :
> Why #1 (argument) is properly replaced as in a "send #1_processor" object
> but not in an object like "pattr @bindto parent::#1_processor". Is it only a
> problem of having caracters (::) before #1 ?

Hi.
Your typed arguments have to be in 1st place.
"send #1_processor" will work but "send processor_#1" won’t.
Here is a workaround :

#P window setfont "Sans Serif" 10.;
#P window linecount 2;
#P comment 203 60 100 9109514 this number box is named "2num";
#P window setfont "Sans Serif" 9.;
#P number 200 102 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname 2num;
#P window linecount 1;
#P newex 144 147 45 9109513 loadbang;
#P number 84 98 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname 1num;
#N vpatcher 622 350 970 580;
#P window setfont "Sans Serif" 9.;
#P newex 168 106 131 9109513 sprintf bindto parent::%ldnum;
#P objectname u153000012[2];
#P newex 127 79 51 9109513 unpack s i;
#P objectname u153000012[1];
#P inlet 127 35 15 0;
#P newex 127 57 57 9109513 patcherargs;
#P objectname u153000012;
#P number 39 84 35 9 0 0 0 139 0 0 0 250 255 59 222 222 222 0 0 0;
#P newex 39 156 40 9109513 pattr;
#X prestore 1 0 32;
#P objectname u196000018;
#P connect 1 0 0 0;
#P connect 5 0 0 0;
#P connect 3 0 2 0;
#P connect 2 0 4 0;
#P connect 4 1 5 0;
#P pop 1;
#P newobj 144 180 40 9109513 p test 2;
#P objectname test;
#P window setfont "Sans Serif" 10.;
#P window linecount 2;
#P comment 72 57 100 9109514 this number box is named "1num";
#P window setfont "Sans Serif" 9.;
#P window linecount 3;
#P comment 103 205 179 9109513 change patcher argument (here with 1 or 2) ,
double-click loadbang and move the yellow number box in the patcher;
#P connect 4 0 2 0;
#P window clipboard copycount 7;


Viewing 5 posts - 1 through 5 (of 5 total)