[sprintf] formatting

Brian H.'s icon

I'm wondering how I can give [sprintf] the specific inlet number to use for a particular variable. The string looks like this:

sprintf pattrforward stuff[INSERT_PATCHER_ARGUMENT]::MoreStuff::INSERT_VALUE_FROM_UI_OBJECT

I need the variable in the 2nd position (UI value) to be the one on the hot inlet.

I also looked at [combine], which is not impossible, but has some issues of its own. Is this possible with [sprintf]? I tried some notations to get it to look at the 2nd inlet and it didn't seem to work (%2i, %i$2, etc.).

Hope that makes some sense...

Thanks,
Brian

jvkr's icon

Have a look at the combine object.

_
johan

Max Patch
Copy patch and select New From Clipboard in Max.

Luke Hall's icon

It is possible with [sprintf] and [combine] although the latter is easier, check out the use of the "triggers" attribute which is built in.

lh

Max Patch
Copy patch and select New From Clipboard in Max.

Brian H.'s icon

Thanks...[combine] worked OK, just had to break it up a bit more than I was thinking. But it came together well. Just to check, there is no way to make a [sprintf] outlet other than the left hot?

Thanks again,
Brian

Luke Hall's icon

Not that I am aware of. You'd have to patch together your own way, perhaps storing the output with [zl reg] and using [trigger] to cause bang this only from the desired inlets. If you want only one inlet other than the first to be the trigger then you could always [pack] your inputs into a list and use [zl rot] to change the order.

lh

seejayjames's icon

Brian H. wrote on Sat, 12 September 2009 01:21Thanks...[combine] worked OK, just had to break it up a bit more than I was thinking. But it came together well. Just to check, there is no way to make a [sprintf] outlet other than the left hot?

just use [trigger], first store the %s or %c or whatever you want to first, then bang the hot inlet to send out the sprintf result.

like if [UI_VALUE] = a float
[t b f]
f to second inlet, then bang to first.

bang won't change the contents, it makes the object spit out what's currently there, similar to lots of other objects like zl, pack, matrixctrl, etc.

Brian H.'s icon

Perfectly fine solution...I get stuck in a loop where I am compelled to think there *must* be a more elegant solution than the one I'm imagining, because often there are some wonderful ones...and then, while this one is not bad at all, there are some that are not so much...

Thanks much,
Brian

seejayjames's icon

watch out for stack overflows in your brain too. max can cause these.