Forums > MaxMSP

formatting data like this……?

April 13, 2009 | 8:13 pm

Hi, i would normally ask my tutor at uni, but i can’t at the moment. I’ve gone through loads of tutorials but i can’t seem to get much progress on formatting my data in the way i want.

i’m reading data from a serial port and if I print, my data looks like this:

print x
print 1
print 1
print y
print 2
print 0
print 3
print
print
print x
print 1
print 2
print y
print 1
print 0
print 0
print 2
print
print

I need the data to look like this:
print 11 203
print 12 1002

Any ideas would be really appreciated!

I’ve trying zl group/pack and a whole bunch of other things but i’m having no luck. If anyone could point me in the right direction, I would be very happy!

Thank you.


April 14, 2009 | 1:27 am

okay i’m using:

"match x nn nn y nn nn nn"

to grab the chunks of data, now the data looks like:

print x 1 1 y 2 0 3

So is their a way of removing the x and y chars from the data and making the 1 1 into 11 etc, so the data looks like

print 11 203

thank you


April 14, 2009 | 1:40 am

[zl filter]?


April 14, 2009 | 1:44 am

Answered too fast!
[zl filter] would be just to filter the x and y.
Here you go with a [sprintf] in addition.
You could also do everything at once with [regexp].
Jean-François.

– Pasted Max Patch, click to expand. –

April 14, 2009 | 1:57 am

thank you so much.

I used [springf %s%s%s%s%s%s%s] to remove the spaces and [zl filter x] to remove the x and same for the y.

I feel like a right newb, but i really didn’t know about the sprintf thing.

Thanks a million, much appreciated Very Happy


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