Forums > MaxMSP

Bug? sprintf + forward

October 5, 2009 | 12:47 am

Hey, maybe its my mistake, but i think i found a strange bug. on the left of this patcher there’s the combination of a sprintf formated message to forward.
max says "forward – First extra argument must be a symbol" same on the right side but a message box between sprintf and forward, working. ?!
(using max 5.0.7)

– Pasted Max Patch, click to expand. –

October 5, 2009 | 6:19 am

I don’t think it’s a bug in [sprintf], but a characteristic of the way the comma works in a message box. The string coming from [sprintf] is treated as one item. In the message box, the comma separates the string into two separate messages. [forward] needs to get two messages: one to tell it where to send, and the other to tell it what to send. When it comes directly from [sprintf] it thinks it is only getting one message.

Try this for an example of the way the comma works when coming directly from [sprintf] and when it comes from a message box.

– Pasted Max Patch, click to expand. –

October 5, 2009 | 10:30 am

Your mistake. No bug.

Sorry to be zen-ishly blunt, but what else can I say?-)

sprintf’s job is not to parse strings using commas to delimit and serialize messages. Sprintf’s job is to build messages of symbols, ints, floats, and (possibly) backslash-escaped special characters. Which is what it does. Replace your first forward object with a print, and you’ll see what sprintf is doing, which is exactly what it’s supposed to do.

Here’s a simpler way to achieve the same effect. Sprintf is nice, but it’s not the only tool in the shed.

– Pasted Max Patch, click to expand. –

There may well be even simpler ways to achieve the effect.


October 5, 2009 | 11:38 pm

i see your point, thanks. I thought most objects would treat a comma separated input message as two serial messages.
cheers


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