Forums > MaxMSP

Trying to convert min:sec to milliseconds – why doesn't this work?

January 5, 2010 | 2:18 am

I’m trying to convert the contents of a textedit field containing a string like this "minutes:seconds" into milliseconds.

I’ve gotten as far as using mxj sbuf with a "split :" message, then feeding this to a "zl group" object, then an unpack, but unpack seems to only returns 0s, even thought the zl seems to be spitting out the correct list.

Why is this happening? Why is the list being ignored by unpack? Also, is there an easier way of doing this in general? It seems long-winded.

– Pasted Max Patch, click to expand. –

January 5, 2010 | 2:30 am

The problem you’re having is that the [zl group] is sending out a list of symbols so the arguments in [unpack] need to be symbols too. Try changing it to [unpack s s] and then it should work. There is an easier way of doing this with [regexp], here’s an example.

lh

– Pasted Max Patch, click to expand. –

January 5, 2010 | 2:42 am

You could do the whole thing like this, and avoid regexp (it confuses me).

– Pasted Max Patch, click to expand. –

January 5, 2010 | 3:02 am

Thanks everyone, the combine and translate objects were new to me, and do the trick.


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