formatting data like this……?
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:
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!
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
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].
----------begin_max5_patcher---------- 378.3ocwT00ZCBCE8Y8Wwk.8MWIIUa21a62wnLrZZ6cnQwjxrsz+6KIp8iMg 4vwJBIbO2a3btmbMG88HqJpEJB7L7J34cz2yyAYA7Zi8H4w0IYwJWYjbgREu QPBZxoE0ZGNiAb5rNXL0AVr58Gh5vJqDJgTGqwB4aUhDcCs7P5TZ.vila2ns Kvx1SI2kixLg1wN+BXwNcGJqEccgTKiyENpeoBiyNScrNYKJ2zCsy31sENxY OdEwMDn2WJZN.gbNkkHEdvkfYNuE8juucIXj1XMvLe6ANPg9byPx+iuvhtO9 hT7goM+lsnJqPodMLAmftkIXOlCuWyI5ueng13QrEMQ2a24PFrFyzhJnF12i uv9ECM7wLzzLtLOb.1Rv.sFWMjLT90mobxvheqeoJ1UkzwR6PAbQHoBkFkt2 ftpFyaTl+55pYKllJboosH4XZYgY.T00tOMMxzg7H61L57yQvxduUGpVYCPq 21O+nVGohBGfhXiPQlfS9eRta12Q -----------end_max5_patcher-----------
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
Forums > MaxMSP