how to include a comma in the output of sprintf?

Feb 4, 2010 at 1:13am

how to include a comma in the output of sprintf?

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?

#48208
Feb 4, 2010 at 1:19am

[ sprintf symout send z%i, min ]

or

[ sprintf symout send z%ld, min ]

#173355
Feb 4, 2010 at 1:20am

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

#173356
Feb 4, 2010 at 3:08am

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.

#173357
Feb 4, 2010 at 7:50am

[t min i] ?

#173358

You must be logged in to reply to this topic.