Forums > MaxMSP

How to close a patch window

September 5, 2006 | 8:09 am

Hi all,

I’m making a kind of patch browser.
I hope to open a patch and close it via messages.

My first idea is "load" message to "pcontrol" object.
But there’s no way to close it. (without modifying target patches)

Second idea is "openfile" and "closefile" messages to Max application.

For example,
; max openfile mysymbol kazoo.pat
then
; max closefile mysymbol

But if user close the patch by himself, the messages doesn;t work any
more.

(I%(B error: closefile: no patcher associated with mysymbol
(I%(B error: openfile: mysymbol: symbol in use

Is it possible to clear symbol in use ?
Or any other idea ?

I’m glad if someone could help me….

Thank you.

Best,
Masayuki Akamatsu


September 5, 2006 | 12:35 pm

there is the dispose message to the thispatcher object.
for more advanced window management look at the wmangle external.

cheers
//yac

> Hi all,
>
> I’m making a kind of patch browser.
> I hope to open a patch and close it via messages.
>
> My first idea is "load" message to "pcontrol" object.
> But there’s no way to close it. (without modifying target patches)
>
> Second idea is "openfile" and "closefile" messages to Max application.
>
> For example,
> ; max openfile mysymbol kazoo.pat
> then
> ; max closefile mysymbol
>
> But if user close the patch by himself, the messages doesn;t work any
> more.
>
> (I%(B error: closefile: no patcher associated with mysymbol
> (I%(B error: openfile: mysymbol: symbol in use
>
> Is it possible to clear symbol in use ?
> Or any other idea ?
>
>
> I’m glad if someone could help me….
>
>
> Thank you.
>
> Best,
> Masayuki Akamatsu
>
>


September 5, 2006 | 2:41 pm

Hi Yacine,

Thank you for reply

On 2006/09/05, at 21:35, Yacine Sebti wrote:

> there is the dispose message to the thispatcher object.

I don’t want to change the target patches.
I want to close the patch that is not mine.

> for more advanced window management look at the wmangle external.

wmangle is not stable (even in Max 4.5), isn’t it?
And it has no function to close the patch.

Thank you.

Best,
Masayuki


September 5, 2006 | 6:00 pm

> I don’t want to change the target patches.
dispose is to close the patcher not to ‘change the target patches’(?).

> I want to close the patch that is not mine.
why would you close other people’s patches.

> wmangle is not stable (even in Max 4.5), isn’t it?
> And it has no function to close the patch.
there I can’t say, I only used it once and I remember it handeled transparancy and other stuff.

here is an example of how to close a patch using [pcontrol] or [thipatcher]

I guess it’s only a misundurstanding, it should work for you as it does for me.

bye
//yac


September 5, 2006 | 6:57 pm

sorry I forgot to post the example.
here it is:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 163 129 30 9109513 close;
#P newex 130 155 41 9109513 pcontrol;
#P message 130 129 28 9109513 open;
#N vpatcher 427 70 1027 470;
#P window setfont "Sans Serif" 9.;
#P newex 204 161 79 9109513 r from_anywhere;
#P window linecount 2;
#P comment 89 125 100 9109513 open/close from within the patcher;
#P window linecount 1;
#P message 84 160 28 9109513 front;
#P inlet 423 132 15 0;
#P message 119 160 68 9109513 clean , dispose;
#N thispatcher;
#Q end;
#P newobj 84 213 54 9109513 thispatcher;
#P connect 5 0 0 0;
#P connect 3 0 0 0;
#P connect 1 0 0 0;
#P pop;
#P newobj 130 213 71 9109513 p sub_to_close;
#P window linecount 2;
#P comment 200 128 100 9109513 open/close from parent patcher;
#P connect 4 0 3 0;
#P connect 3 0 1 0;
#P connect 2 0 3 0;
#P window clipboard copycount 5;


September 6, 2006 | 12:20 am

Thank you for your reply and example, Yacine.

On 2006/09/06, at 3:00, Yacine Sebti wrote:

> why would you close other people’s patches.

My explanation is not so good. Sorry.
Here’s a patch I’m working on (and it is not completed).

http://max.iamas.ac.jp/2061OR.zip

This is an object browser (in Japanese).
You can open a help patch on double-clicking on the right list.
(The left is a product list and the middle is a category list.)
I hope to close a help patch before another help is opened.

I’m opening standard help patches (of course, they are not mine).
Thus I don’t want to modify them.

In this browser, it is not too bad to open multiple help patches.
But in another browser, it is important to keep only one patch open.

Thank you.

Best,
Masayuki


September 7, 2006 | 7:31 am

Masayuki Akamatsu wrote:
> But if user close the patch by himself, the messages doesn;t work any
> more.

If you keep track what is opened, you can close them with a closebang
object in case the patcher which opened it is closed by the user…

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


September 7, 2006 | 10:35 am

the only solution I found is to dinamicly create a bpatcher with the help file in it.
I also found a way to extract the size and position of the original window from the binary file to
reproduce them.
the problem is you can’t edit the help file to copy some elements.
otherwize this works well… have a look.

best
//yac

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 254 155 60 9109513 auto-open;
#P message 145 133 54 9109513 thispatcher;
#P message 114 133 29 9109513 swap;
#P message 88 133 23 9109513 pak;
#P toggle 237 155 15 0;
#P window linecount 2;
#P comment 401 156 161 9109513 as there is one inlet open and close works fine with pcontrol;
#P window linecount 1;
#P message 138 156 52 9109513 bangbang;
#P message 99 156 36 9109513 bogus;
#P message 364 156 34 9109513 close;
#N vpatcher 96 110 658 565;
#P origin 81 77;
#P hidden inlet 780 418 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#N vpatcher 200 216 843 523;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 10 171 28 9109513 front;
#P newex 10 149 27 9109513 gate;
#P inlet 219 57 15 0;
#P window linecount 0;
#P message 50 149 194 9109513 window size $1 $2 $3 $4 , window exec , clean;
#N vpatcher 15 55 698 541;
#P outlet 385 449 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P newex 450 391 27 9109513 !-;
#P newex 419 391 27 9109513 !-;
#P newex 419 416 28 9109513 pack;
#P newex 419 359 58 9109513 unpack i i i i;
#P newex 198 274 27 9109513 +;
#P newex 226 250 30 9109513 * 256;
#P newex 198 227 38 9109513 unpack;
#P newex 198 204 48 9109513 zl group 2;
#P newex 23 321 21 9109513 b 1;
#P newex 5 290 28 9109513 sel 3;
#P newex 135 316 53 9109513 t 1 b b 3;
#N counter 3;
#X flags 0 0;
#P newobj 5 268 66 9109513 counter 3;
#P number 94 384 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 385 330 40 9109513 zl group;
#P newex 94 316 40 9109513 t 1 b 2;
#P newex 130 175 42 9109513 gate 3 1;
#P newex 94 225 46 9109513 sel 17 18;
#N counter;
#X flags 0 0;
#P newobj 191 109 66 9109513 counter;
#P message 191 78 36 9109513 jam 28;
#P outlet 419 449 15 0;
#P window linecount 1;
#P newex 162 136 40 9109513 filein;
#P inlet 162 95 15 0;
#P fasten 5 1 10 0 117 256 10 256;
#P lcolor 1;
#P fasten 5 0 10 0 99 256 10 256;
#P lcolor 1;
#P connect 10 0 12 0;
#P connect 12 1 13 0;
#P fasten 6 0 5 0 135 209 99 209;
#P connect 5 0 7 0;
#P fasten 11 3 9 0 182 378 99 378;
#P fasten 11 0 9 0 140 378 99 378;
#P fasten 7 2 9 0 129 378 99 378;
#P connect 7 0 9 0;
#P fasten 9 0 6 0 99 408 78 408 78 167 135 167;
#P fasten 5 1 11 0 117 262 140 262;
#P fasten 4 0 1 0 196 132 167 132;
#P connect 0 0 1 0;
#P connect 1 0 6 1;
#P fasten 1 2 3 0 197 159 261 159 261 74 196 74;
#P fasten 13 0 4 0 28 415 378 415 378 102 196 102;
#P fasten 11 2 4 0 168 381 315 381 315 107 196 107;
#P fasten 11 1 4 0 154 381 315 381 315 107 196 107;
#P fasten 7 1 4 0 114 381 315 381 315 107 196 107;
#P connect 3 0 4 0;
#P fasten 6 2 14 0 167 199 203 199;
#P connect 14 0 15 0;
#P connect 15 0 17 0;
#P fasten 16 0 17 1 231 271 220 271;
#P connect 15 1 16 0;
#P fasten 6 1 8 0 151 308 390 308;
#P fasten 17 0 8 0 203 304 390 304;
#P fasten 12 0 8 0 10 312 390 312;
#P lcolor 1;
#P connect 8 0 22 0;
#P fasten 8 0 18 0 390 354 424 354;
#P connect 18 0 20 0;
#P connect 20 0 19 0;
#P connect 19 0 2 0;
#P connect 18 2 20 1;
#P fasten 21 0 19 1 455 413 442 413;
#P connect 18 1 21 0;
#P connect 18 3 21 1;
#P pop;
#P newobj 50 111 90 9109513 p size from file;
#P newex 50 86 81 9109513 prepend read;
#P newex 267 145 71 9109513 pack i i s;
#P message 267 167 320 9109513 script delete help_pat , script new help_pat bpatcher 0 0 $1 $2
0 0 $3 0;
#P inlet 50 60 15 0;
#P outlet 50 197 15 0;
#P fasten 7 0 8 0 224 78 15 78;
#P lcolor 1;
#P connect 8 0 9 0;
#P fasten 5 0 8 1 55 139 32 139;
#P connect 1 0 4 0;
#P connect 4 0 5 0;
#P connect 5 0 6 0;
#P fasten 9 0 0 0 15 190 55 190;
#P connect 6 0 0 0;
#P fasten 2 0 0 0 272 190 55 190;
#P fasten 5 1 3 0 135 140 272 140;
#P connect 3 0 2 0;
#P fasten 1 0 3 2 55 81 332 81;
#P pop;
#P hidden newobj 730 438 60 9109513 p;
#N thispatcher;
#Q end;
#P hidden newobj 730 461 54 9109513 thispatcher;
#P hidden inlet 730 418 15 0;
#P bpatcher 0 0 562 455 0 0 thispatcher.help 0;
#P objectname help_pat;
#P hidden connect 1 0 3 0;
#P hidden connect 3 0 2 0;
#P hidden connect 4 0 3 1;
#P pop;
#P newobj 88 219 52 9109513 p help;
#P message 193 156 32 9109513 abs~;
#P newex 331 187 45 9109513 pcontrol;
#P message 331 156 32 9109513 open;
#P newex 88 189 122 9109513 sprintf ./max-help/%s.help;
#P window linecount 3;
#P comment 86 72 219 9109513 you need to send a complete path to open the help-file or put
./max-help in your folder list but then you might have problems with sub-folders;
#P fasten 13 0 1 0 150 153 93 153;
#P fasten 12 0 1 0 119 153 93 153;
#P fasten 11 0 1 0 93 186 93 186;
#P fasten 10 0 5 1 242 212 135 212;
#P fasten 4 0 1 0 198 180 93 180;
#P fasten 7 0 1 0 104 180 93 180;
#P fasten 8 0 1 0 143 180 93 180;
#P connect 1 0 5 0;
#P fasten 3 0 5 0 336 210 93 210;
#P connect 6 0 3 0;
#P connect 2 0 3 0;
#P window clipboard copycount 15;


September 9, 2006 | 9:15 am

Hi Yacine,

On 2006/09/07, at 19:35, Yacine Sebti wrote:

> the only solution I found is to dinamicly create a bpatcher with
> the help file in it.

It looks so nice.

> I also found a way to extract the size and position of the original
> window from the binary file to
> reproduce them.

Great work!

> the problem is you can’t edit the help file to copy some elements.
> otherwize this works well… have a look.

Sure. But it might be useful for other purpose.

Thank you again.

Best,
Masayuki


September 10, 2006 | 8:50 am

hello Masayuki,

i found two solutions to your problem:

- one is using the javascript object-model in max.
access the frontwindow then iterate through all the open windows
until you find the one that has the same title as the patcher you
want to close. then send the "wclose" message to the window’s
this.patcher.

- the other one is using the [; max openfile foo filename] message to
open and the corresponding [; max closenfile foo] message to close
the file.

see attached patches and script.

cheers

/*j

//////////////////////////////
save as patcher_close.js
//////////////////////////////

/*
* javascript to close remote patcher by name – jasch 20060909
*/

function close(patchername)
{
var w = max.frontpatcher.wind;
while(w){
if(w.title == patchername){
w.assoc.message("dispose");
}
w = w.next;
}
}

//////////////////////////////
save as helpbrowser.mxb
//////////////////////////////

max v2;
#N vpatcher 778 54 1037 330;
#P window setfont "Sans Serif" 9.;
#P newex 101 149 36 196617 zl reg;
#P newex 32 96 30 196617 t s b;
#P newex 101 171 71 196617 prepend close;
#P newex 101 193 97 196617 js patcher_close.js;
#P newex 127 127 51 196617 strippath;
#P newex 32 193 47 196617 pcontrol;
#P newex 32 171 66 196617 prepend load;
#P message 32 38 92 196617 prefix ./max-help;
#P user ubumenu 32 66 100 196617 0 1 1 0;
#X add;
#X prefix_set 0 1 0;
#P connect 1 0 0 0;
#P connect 0 1 7 0;
#P connect 7 0 2 0;
#P connect 2 0 3 0;
#P connect 7 1 8 0;
#P connect 8 0 6 0;
#P connect 6 0 5 0;
#P connect 7 0 4 0;
#P connect 4 0 8 1;
#P pop;

//////////////////////////////
save as helpbrowser2.mxb
/////////////////////////////

max v2;
#N vpatcher 182 69 724 497;
#P origin 0 -22;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 134 186 114 196617 t s b;
#P newex 134 207 80 196617 prepend symbol;
#P newex 238 206 54 196617 onebang 1;
#P window linecount 2;
#P message 282 229 130 196617 ; max closefile __browse__;
#P message 134 229 142 196617 ; max openfile __browse__ $1;
#P window linecount 1;
#P message 225 136 33 196617 clear;
#P message 132 136 92 196617 prefix ./max-help;
#P user ubumenu 132 160 281 196617 0 1 1 0;
#X setrgb 0 0 191 226 233 253 190 190 190 255 255 255 141 141 141 112
112 112;
#X prefix_set 0 1 ./max-help/ 0;
#P connect 1 0 0 0;
#P fasten 2 0 0 0 230 154 137 154;
#P fasten 0 1 7 0 272 182 139 182;
#P connect 7 0 6 0;
#P connect 6 0 3 0;
#P connect 7 1 5 0;
#P connect 5 1 4 0;
#P pop;

(the problem with this approach is that when you close the patcher in
another way, the symbol __browse__ doesn’t get freed, and therefore
you can’t assign a new file to that name. solution: incrementally
number your symbols and keep track of the number $1_browse__ etc.)


September 10, 2006 | 11:44 am

Hi jasch,

On 2006/09/10, at 17:50, /*j wrote:

> – one is using the javascript object-model in max.

Perfect !!
It’s suitable to my situation.
Thank you very much.

Best,
Masayuki


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