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

Jan 5, 2010 at 2:18am

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

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. –
#47561
Jan 5, 2010 at 2:30am

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. –
#171072
Jan 5, 2010 at 2:42am

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

– Pasted Max Patch, click to expand. –
#171073
Jan 5, 2010 at 3:02am

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

#171074

You must be logged in to reply to this topic.