Forums > MaxMSP

Problems setting message

January 9, 2008 | 4:57 am

I’m having a problem setting the value of a message box. I’m accomplishing what I need to do, but I’m quite sure that my approach is not the best. I need to be able to dynamically update the contents of a message box that can be banged out in a format appropriate for a line object (i.e., "0., 6.931024 15000"). In fact, this is exactly the message I need, and I need to be able to update the duration.

I tried simply a message box with "set 0., 6.931024 $1", but this includes the backslash in the message box being set. Without the backslash, the comma is not escaped and the receiving message box is set to "0."

In the following patch, you can see how I’ve finagled it to work, but I would appreciate any insight on how to accomplish this more appropriately, efficiently, elegantly, etc.

Thank you,
Brennon

max v2;
#N vpatcher 567 213 825 492;
#P window setfont "Sans Serif" 9.;
#P message 39 192 135 196617 0. , 6.931024 177.;
#P button 39 97 15 0;
#P newex 39 117 43 196617 delay 5;
#P message 98 165 106 196617 prepend \, 6.931024;
#P message 39 164 57 196617 prepend 0.;
#P newex 39 138 30 196617 t b b;
#P flonum 39 49 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 39 72 39 196617 set $1;
#P connect 1 0 0 0;
#P connect 0 0 6 0;
#P connect 6 0 5 0;
#P connect 5 0 2 0;
#P connect 2 0 3 0;
#P fasten 0 0 7 0 44 92 34 92 34 183 44 183;
#P connect 3 0 7 0;
#P fasten 4 0 7 0 103 183 44 183;
#P fasten 2 1 4 0 64 159 103 159;
#P pop;


January 9, 2008 | 6:59 am

[sprintf] is your friend
/dan

max v2;
#N vpatcher 300 180 922 459;
#P window setfont "Sans Serif" 9.;
#P flonum 117 70 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 117 196 135 196617 0. , 6.931024 0.;
#P newex 117 126 144 196617 sprintf set 0.\, 6.931024 %f;
#P connect 2 0 0 0;
#P connect 0 0 1 0;
#P pop;

Quote: Brennon Bortz wrote on Tue, 08 January 2008 21:57
—————————————————-
> I’m having a problem setting the value of a message box. I’m accomplishing what I need to do, but I’m quite sure that my approach is not the best. I need to be able to dynamically update the contents of a message box that can be banged out in a format appropriate for a line object (i.e., "0., 6.931024 15000"). In fact, this is exactly the message I need, and I need to be able to update the duration.
>
>
—————————————————-


January 9, 2008 | 7:34 am

Wonderful! Thanks for your help.

Best,
Brennon


January 9, 2008 | 7:41 am

Brennon Bortz schrieb:
> In the following patch, you can see how I’ve finagled it to work, but
> I would appreciate any insight on how to accomplish this more
> appropriately, efficiently, elegantly, etc.

You have to know what the comma does. This question is coming up a lot
on the list. Usually there is no initial mentioning of the purpose, but
its always the wish to drive a line or line~ object. If you get yourself
to ask how to achieve the real purpose, you’d probably find out yourself
easier as well…

Beside the sprintf solution mentioned, (which is more confusing for a
beginner than a message box with a comma… ;-) there are several ways
to drive a line, the easiest is the message box with a comma by the way…

Stefan

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 39 104 50 196617 print;
#P message 39 79 94 196617 0. , 6.931024 $1;
#P flonum 39 49 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P window clipboard copycount 3;


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


January 9, 2008 | 7:45 am

Stefan Tiedje schrieb:
> there are several ways to drive a line, the easiest is the message
> box with a comma by the way…

I forgat to paste the other:

#P window setfont "Sans Serif" 9.;
#P flonum 239 114 60 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 140 114 60 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 239 58 76 196617 t 6.931024 i 0;
#P newex 239 89 77 196617 line 0.;
#P flonum 239 34 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 140 89 50 196617 line 0.;
#P message 140 60 94 196617 0. , 6.931024 $1;
#P flonum 140 34 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 39 89 50 196617 print;
#P message 39 60 94 196617 0. , 6.931024 $1;
#P flonum 39 34 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P connect 8 2 7 0;
#P connect 8 1 7 1;
#P connect 8 0 7 0;
#P connect 7 0 10 0;
#P connect 4 0 5 0;
#P connect 5 0 9 0;
#P connect 6 0 8 0;
#P connect 3 0 4 0;
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P window clipboard copycount 11;


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


January 9, 2008 | 8:44 am

Quote: Stefan Tiedje wrote on Tue, 08 January 2008 23:41
—————————————————-

> You have to know what the comma does.

Hello Stefan,

Thanks for your help. If I understand your comments and patches correctly, I believe you’re trying to point out that the comma breaks a message into multiple successive messages, which I do understand. However, what I’m trying to do is reset the contents of a single message to such a compound message, including the comma. As one with programming experience, the sprintf object makes perfect sense to me, and I now notice that it is referenced in the help file for the message object–please forgive my hastiness. This same experience is what led me to believe that escaping the comma in the "set" message with a backslash character would avoid its literal interpretation in the "set" message.

Nonetheless, you seem to hint that there is more than one way to skin the proverbial cat, but your patch is only showing several ways to drive a line–which isn’t exactly what I’m trying to do. Is there another way to format the message which will in turn drive the line? If sprintf is the best way to go, however, this cat is done skunned.

Thanks again!,
Brennon


January 9, 2008 | 11:14 am

Brennon Bortz schrieb:
> Is there another way to format the message which will in turn drive
> the line? If sprintf is the best way to go, however, this cat is done
> skunned.

It depends, if you really need a changing message box with a comma in
it, sprintf is fine.
However, for driving a line you don’t need a message box at all. (See
the trigger example).
But a message box with several $1, $x replacements is a convenient way
to massage messages, including existing commas…
(f.e. [pack f f f]->[$1, $2 $3] for a line control…)

I just don’t know why you want to change the content of the message box
itself, but I am sure you have a reason…

Stefan


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


January 10, 2008 | 6:57 am

Quote: Stefan Tiedje wrote on Wed, 09 January 2008 03:14
—————————————————-
> I just don’t know why you want to change the content of the message box
> itself, but I am sure you have a reason…
>

Only to save myself the time of reworking a boatload of subpatches. Next time I’ll know better!

Thanks Stefan,
Brennon


January 11, 2008 | 7:16 pm

Quote: Brennon Bortz wrote on Wed, 09 January 2008 22:57
—————————————————-
> Quote: Stefan Tiedje wrote on Wed, 09 January 2008 03:14
> —————————————————-
> > I just don’t know why you want to change the content of the message box
> > itself, but I am sure you have a reason…
> >
>
> Only to save myself the time of reworking a boatload of subpatches. Next time I’ll know better!
>
> Thanks Stefan,
> Brennon
—————————————————-

It has also come up recently that this message to line:

"0., 6.931024 15000"

is the same as

"0. 0 6.931024 15000"

I’d ditch the comma entirely, and work with a simpler message.

mz


January 11, 2008 | 8:10 pm

At 11:16 AM -0800 1/11/08, mzed wrote:
>It has also come up recently that this message to line:
>
>"0., 6.931024 15000"
>
>is the same as
>
>"0. 0 6.931024 15000"
>
>I’d ditch the comma entirely, and work with a simpler message.

I think that’s only true for line~ (which understands lists of time/level pairs), but not for line.

-C


Chris Muir | "There are many futures and only one status quo.
cbm@well.com | This is why conservatives mostly agree,
http://www.xfade.com | and radicals always argue." – Brian Eno


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