Forums > MaxMSP

parsing spaces out of the text object


ico
April 26, 2007 | 6:00 pm

Hi all,

I finally have a working serial object (thanks to Jeremy), but now I have a
different dilemma. Namely, I have converted incoming data from the serial
object into ascii letters. Then, I threw them into the "text" object in
order to parse incoming data. However, this still leaves a "space" between
the letters even though I’ve tried to filter out 32 (space) from the stream
using select object (before I converted it into ascii). So, how can I
either:

1) remove spaces in the text object between each ascii sign (this is
apparently how the serial object spits out data nn, yet 32 does not
filter out the last space nor does itoa)

2) use some other object to convert data stream into text

Help is most appreciated.

Best wishes,

Ico


April 26, 2007 | 6:33 pm

Ivica Ico Bukvic skrev:
> So, how can I
> either:
>
> 1) remove spaces in the text object between each ascii sign (this is
> apparently how the serial object spits out data nn, yet 32 does not
> filter out the last space nor does itoa)
Will this method of removing spaces work for you?

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 635 483 123 9109513 these are removed spaces.;
#P newex 635 510 66 9109513 regexp \\s \\;
#P window setfont "Sans Serif" 9.;
#P newex 635 537 57 196617 prepend set;
#P message 635 561 119 196617 theseareremovedspaces.;
#P connect 3 0 2 0;
#P connect 2 0 1 0;
#P connect 1 0 0 0;
#P window clipboard copycount 4;



ico
April 26, 2007 | 9:55 pm

> > filter out the last space nor does itoa)
> Will this method of removing spaces work for you?
>
>
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P message 635 483 123 9109513 these are removed spaces.;
> #P newex 635 510 66 9109513 regexp \\s \\;
> #P window setfont "Sans Serif" 9.;
> #P newex 635 537 57 196617 prepend set;
> #P message 635 561 119 196617 theseareremovedspaces.;
> #P connect 3 0 2 0;
> #P connect 2 0 1 0;
> #P connect 1 0 0 0;
> #P window clipboard copycount 4;

Well, this works with message, but number still does not understand the
output. If I send in a "7 3", number complains it has received "73" which
it does not understand. Even if I pass it through the message and then bang
the message into the number it still complains about it even though visually
message shows "73".

Any ideas?

Best wishes,

Ico



ico
April 26, 2007 | 10:14 pm

Never mind, figured it out (use fromsymbol).

Many thanks!

Best wishes,

Ico


April 26, 2007 | 10:17 pm

Ivica Ico Bukvic skrev:
>>> filter out the last space nor does itoa)
>>>
>> Will this method of removing spaces work for you?
>>
>>
>> #P window setfont "Sans Serif" 9.;
>> #P window linecount 1;
>> #P message 635 483 123 9109513 these are removed spaces.;
>> #P newex 635 510 66 9109513 regexp \\s \\;
>> #P window setfont "Sans Serif" 9.;
>> #P newex 635 537 57 196617 prepend set;
>> #P message 635 561 119 196617 theseareremovedspaces.;
>> #P connect 3 0 2 0;
>> #P connect 2 0 1 0;
>> #P connect 1 0 0 0;
>> #P window clipboard copycount 4;
>>
>
> Well, this works with message, but number still does not understand the
> output. If I send in a "7 3", number complains it has received "73" which
> it does not understand. Even if I pass it through the message and then bang
> the message into the number it still complains about it even though visually
> message shows "73".
[fromsymbol] of course!

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 635 523 59 9109513 fromsymbol;
#P number 635 543 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 635 483 34 9109513 4 5 76;
#P newex 635 503 66 9109513 regexp \\s \\;
#P connect 3 0 2 0;
#P connect 0 0 3 0;
#P connect 1 0 0 0;
#P window clipboard copycount 4;


April 26, 2007 | 10:41 pm

maybe this will work:

max v2;
#N vpatcher 100 100 700 500;
#P origin 187 225;
#P window setfont "Sans Serif" 9.;
#P newex 153 90 48 196617 loadbang;
#P message 153 123 57 196617 separator;
#P newex 97 146 62 196617 prepend set;
#P message 97 168 264 196617 sendtosymbolseparatormessagewithnoarg7373;
#P newex 96 123 54 196617 tosymbol;
#P message 80 57 249 196617 send tosymbol separator message with no arg 7 3 73;
#P connect 0 0 1 0;
#P connect 4 0 1 0;
#P connect 1 0 3 0;
#P connect 3 0 2 0;
#P connect 5 0 4 0;
#P pop;



G
April 27, 2007 | 8:11 am

hi,

if your message length is known and constant you can do this :

#P window setfont "Sans Serif" 9.;
#P number 89 169 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 54 108 80 196617 sprintf %i%i%i;
#P message 55 41 34 196617 1 2 2;
#P connect 0 0 1 0;
#P connect 1 0 2 0;
#P window clipboard copycount 3;

G


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