Forums > MaxMSP

how to include a comma in the output of sprintf?

February 4, 2010 | 1:13 am

I am using sprintf to assemble some command strings, and I need to include a comma character

For example, my sprintf looks like this:

sprintf symout send z%i min

and I want the output to look like

send z1, min < - note the comma

It looks like I can’t include the standard ASCII escaping, eg 54 for comma.

How can I do this?


February 4, 2010 | 1:19 am

[ sprintf symout send z%i, min ]

or

[ sprintf symout send z%ld, min ]


February 4, 2010 | 1:20 am

You can use a backslash to escape a reserved character in objects like [sprintf] and [expr]. Try without the "symout" argument otherwise it will all be one message and won’t work if you try to send it to [forward].

[sprintf send z%i, min]

lh


February 4, 2010 | 3:08 am

If I don’t include symout then forward kicks back "forward: first extra argument must be a symbol".

If I do include symout, then the forward doesn’t seem to take effect.

What seems to work is (t b i) to fire off the (sprintf send z%i) and then (min).

Is there a simpler way to do this? I just want to selectively send messages to a number of consecutively named (receive) objects.


February 4, 2010 | 7:50 am

[t min i] ?


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