Forums > MaxMSP

Reverse of sprintf? / Converting formatted message from string

August 20, 2013 | 8:46 pm

Hello, well this is infuriatingly simple but I cannot come up with any ideas perhaps due to my limited understanding of sprintf / C+

I have a M4L patch pasted below where I want to trigger a bang when a formatted message crosses a threshold. I am successfully doing this but I’m curious if it is possible another way…

In this case I want to know if I can take a message in the format hour:min:sec:ms like 00:00:30:000 and unpack that the way fromsymbol works with a message like "blah yah boo." Am I insane or are these colons a problem? I’ve looked at regexp too but cannot get that to work. The doc on sprintf below suggests sscanf is what I’m looking for perhaps, but in the Max world?

As always, thanks for any help on informing me what an idiot I am.


— Pasted Max Patch, click to expand. —
August 20, 2013 | 9:19 pm

If you just want it to work like fromsymbol, you can actually use fromsymbol @separator : and it will output the time as a list without the colons.

If you are interested to see how to do that with regexp, check out the following patch. Hope that is helpful!

— Pasted Max Patch, click to expand. —
August 20, 2013 | 9:46 pm

bless your heart! yes, perfection. thanks so much.

August 21, 2013 | 12:10 am

hmm.. I posted the same use of regexp your other thread of the same name (!). I guess I’ll repost my reply in your rethread. ha.

You can hit it from two angles.. Either create a list from the sprintf’d format with regexp or bypass the sprintf formatting and output a secondary list of time values from the subpatch. In either case, sel isn’t gonna hack it. match is the ticket.

— Pasted Max Patch, click to expand. —

— Pasted Max Patch, click to expand. —
August 21, 2013 | 1:04 pm

sorry on that rethread, must have double-clicked on post yet i cannot figure out how to erase it.

this is so helpful – match is my new favorite object!

August 21, 2013 | 1:18 pm

yeah, it works just like a combination lock. It’s great.

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

Forums > MaxMSP