Forums > MaxMSP

Convert pattstorage message when @outputmode 1

March 14, 2006 | 11:27 pm

Hi list,

I would like to convert messages who come from the pattrstorage when then @outpumode is active (1). I have a really big patch with a lot of subpatch.Pattrstorage right outlet messages are in this form :
subfolder::objectname value
I would like seprate it and use :
ojbectname value.

I tried [fromsymbol] without sucess.

Cheers,

Nico.


March 14, 2006 | 11:47 pm

how about

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 239 212 32 196617 print;
#P newex 239 179 70 196617 regexp ::(.*);
#P message 235 157 138 196617 subfolder::objectname value;
#P connect 1 1 2 0;
#P connect 0 0 1 0;
#P window clipboard copycount 3;

-A


March 15, 2006 | 1:44 am

Hi A.

Thanks a lot ! I know this object but i don’t understand all his functions. I tried to understand it by read the manual but with no sucess… Anyway, may be you can help me one more time, my string are more complicate :

subfolder::patcher::objectname[2] 15

1] I would like separate it like this :
subfolder
patcher
objectname
[2] (without the [] sign)
15

2]
I made a patch (below) with the patch that you send me. the outputing regxp message contains "" sign, so I have to use [fromsymbol]. Is it possible to have a string without "" signs?

max v2;
#N vpatcher 25 70 837 528;
#P window setfont "Sans Serif" 9.;
#P number 163 395 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname value[2];
#P number 121 395 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname value[1];
#P window linecount 1;
#N thispatcher;
#Q end;
#P newobj 127 304 54 9109513 thispatcher;
#P button 212 83 15 0;
#P message 308 142 154 9109513 subfolder::objectname::value[2] 40;
#P newex 127 252 59 9109513 fromsymbol;
#P newex 127 279 118 9109513 sprintf script send %s %ld;
#P newex 135 218 58 9109513 regexp ::(.*);
#P newex 135 186 58 9109513 regexp ::(.*);
#P message 145 143 154 9109513 subfolder::objectname::value[1] 35;
#P fasten 2 1 4 0 156 242 132 242;
#P connect 4 0 3 0;
#P connect 3 0 7 0;
#P fasten 0 0 1 0 150 173 140 173;
#P fasten 5 0 1 0 313 172 140 172;
#P connect 1 1 2 0;
#P connect 6 0 0 0;
#P connect 6 0 5 0;
#P pop;


March 15, 2006 | 3:07 am

I dunno. This stuff gives me a headache. I just try and get it to work, I’m sure there are better ways to write regexp than what I always end up with.

the fromsymboil object in part 2 is probably how I would do it – but I have no idea of what you are trying to do or why…..

:)

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 532 305 59 9109513 fromsymbol;
#P button 388 114 15 0;
#P newex 509 254 108 9109513 regexp [\\w]*::[\\w]*::(.*);
#P newex 291 333 57 9109513 prepend set;
#P newex 215 335 57 9109513 prepend set;
#P newex 139 338 57 9109513 prepend set;
#P number 368 360 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 415 359 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P user textedit 294 357 365 380 32896 139 9;
#P user textedit 213 360 284 383 32896 139 9;
#P user textedit 129 364 200 387 32896 139 9;
#P newex 250 298 72 9109513 unpack s s s i i;
#P button 261 112 15 0;
#P number 573 424 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname value[2];
#P number 531 424 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname value[1];
#N thispatcher;
#Q end;
#P newobj 533 373 54 9109513 thispatcher;
#P button 241 113 15 0;
#P message 315 188 154 9109513 subfolder::objectname::value[2] 40;
#P newex 533 348 118 9109513 sprintf script send %s %ld;
#P newex 209 260 161 9109513 regexp (.*)::(.*)::(.*)\\[(\\d*)\\]\\s(\\d*);
#P message 319 166 154 9109513 subfolder::objectname::value[1] 35;
#P connect 9 2 17 0;
#P connect 9 1 16 0;
#P connect 1 1 9 0;
#P connect 9 4 13 0;
#P connect 9 3 14 0;
#P connect 9 0 15 0;
#P connect 20 0 2 0;
#P connect 18 1 20 0;
#P connect 3 0 1 0;
#P connect 3 0 18 0;
#P connect 0 0 1 0;
#P connect 0 0 18 0;
#P connect 19 0 3 0;
#P connect 19 0 0 0;
#P connect 17 0 12 0;
#P connect 16 0 11 0;
#P connect 15 0 10 0;
#P connect 8 0 3 0;
#P connect 4 0 0 0;
#P connect 2 0 5 0;
#P window clipboard copycount 21;

-A


March 15, 2006 | 7:10 am

Nico wrote:
> I would like to convert messages who come from the pattrstorage when
> then @outpumode is active (1). I have a really big patch with a lot
> of subpatch.Pattrstorage right outlet messages are in this form :
> subfolder::objectname value I would like seprate it and use :
> ojbectname value.

something like this?

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 150 261 195 196617;
#P newex 150 233 62 196617 prepend set;
#P newex 60 211 100 196617 zl slice 1;
#P newex 60 189 62 196617 fromsymbol;
#P message 60 293 195 196617;
#P newex 60 265 62 196617 prepend set;
#P message 60 61 154 196617 subfolder::objectname value;
#P newex 60 85 100 196617 zl slice 1;
#P newex 60 162 26 196617 itoa;
#P newex 60 109 26 196617 atoi;
#P newex 60 133 84 196617 substitute 58 32;
#P message 150 156 195 196617;
#P newex 150 133 62 196617 prepend set;
#P connect 10 1 11 0;
#P connect 11 0 12 0;
#P connect 10 0 7 0;
#P connect 9 0 10 0;
#P connect 4 0 9 0;
#P connect 7 0 8 0;
#P connect 5 1 0 0;
#P connect 0 0 1 0;
#P connect 2 0 4 0;
#P connect 3 0 2 0;
#P connect 5 0 3 0;
#P connect 6 0 5 0;
#P window clipboard copycount 13;

[][] [][][] [][] [][][]
[][][][][][][][][][][][][][][]

Stefan Tiedje
Klanggestalter
Electronic Composition
&
Improvisation

/~~~~~
\ /|() ()|
))))) )| | |( \
/// _/)/ )))))
___/ ///

————————-x—-
–_____———–|———–
–(_|_ —-|—–|—–()—-
– _|_)—-|—–()———–
———-()————x—–

14, Av. Pr. Franklin Roosevelt,
94320 Thiais, France
Phone at CCMIX +33-1-57 42 91 09


March 15, 2006 | 9:31 am

hi nico,

apart from the regexp solutions shown, slicing the string is
something javascript can do well.
see attached script and patch.

let me also mention the C-string library objects in my collection of
externals (http://www.jasch.ch/dl).
cutting a string is something easily achieved: first use [strrchr :]
to find the last colon’s position in the string, then set [strrcut]
with this value and finally slice your string.
the same technique is also useful to slice file-paths at the last slash.
also shown in the attached patch.

hth

/*j

________________
save as stringslicerev.js

a = new Array();
s = new String();
var split;

function anything()
{
a = (arrayfromargs(messagename,arguments)); // fill everythin
into the Array (List)
s = a.shift(); // put first element into string and remove it
from Array
split = s.lastIndexOf(":"); // find last occurence of ":"
outlet(0, s.slice(split+1, s.length), a); // output sliced
symbol and the rest of the Array
}

—————
save as stringslice.pat

max v2;
#N vpatcher 25 70 837 528;
#P button 373 105 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 389 160 178 196617 subfolder::objectname::value[2] 140;
#P message 374 140 178 196617 subfolder::objectname::value[1] 135;
#P comment 463 252 121 196617 reverse cut at last colon;
#P newex 127 212 98 196617 js stringslicerev.js;
#P newex 374 270 76 196617 zl join;
#P newex 374 205 76 196617 zl slice 1;
#P newex 374 249 43 196617 strrcut;
#P newex 386 226 51 196617 strrchr :;
#P number 353 373 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname value[2];
#P number 311 373 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname value[1];
#N thispatcher;
#Q end;
#P newobj 127 335 68 196617 thispatcher;
#P button 127 101 15 0;
#P message 141 160 178 196617 subfolder::objectname::value[2] 40;
#P newex 127 310 137 196617 sprintf script send %s %ld;
#P message 127 139 178 196617 subfolder::objectname::value[1] 35;
#P comment 463 229 73 196617 find last colon;
#P connect 4 0 1 0;
#P connect 3 0 12 0;
#P connect 1 0 12 0;
#P connect 11 0 2 0;
#P connect 12 0 2 0;
#P connect 2 0 5 0;
#P connect 4 0 3 0;
#P connect 16 0 14 0;
#P connect 14 0 10 0;
#P connect 15 0 10 0;
#P connect 10 0 9 0;
#P connect 8 0 9 0;
#P connect 9 0 11 0;
#P connect 10 0 8 0;
#P connect 16 0 15 0;
#P connect 10 1 11 1;
#P pop;


March 15, 2006 | 11:18 am

Have a look at the Jamona components for some great ideas on this subject…
By the way, cheers for jamona !! great structure !


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