Newbie: Text Handling or Extra

Dec 30, 2006 at 6:31pm

Newbie: Text Handling or Extra

Would anyone give me some pointers on handling text?

It strikes me that a lot of user interface issues can involve text, such as a list of pictures, or sounds, or external files of parameters, which you then use effectively as a control (or source) for something later on.

What should I be looking for in “dynamic” text handling?

i.e.
Can Max/MSP handle text lists?
Can the user search and filter such lists?
Can I update such lists on the fly?
In what ways can I use words as control data (ie more than a list index, if the list is dynamic)?
Can I analyse the characters/words to create numeric values I can then process?

And/or are there any add-on modules which can handle or integrate text usage?
Is anyone up for creating such (for money)?

For instance, can I use javascript to handle my words and what then is the best way of integrating that output as a max/msp control ?

Many thanks.

#29430
Dec 30, 2006 at 6:43pm

#92036
Dec 30, 2006 at 7:14pm

Thanks for the super fast reply Julien!

The COLL tip will save me a lot of time.

Just one immediate question;

If you have a long text list and you want to compare and output those lines which contain a certain word, can that be done ?

i.e.
criteria word = fish

long list = fishswim, fishjump, swimjump, bluefish

output = fishswim, fishjump, bluefish

Many thanks.

#92037
Dec 30, 2006 at 7:24pm

Quote: midiwhale wrote on Sat, 30 December 2006 20:14
—————————————————-
> If you have a long text list and you want to compare and output those lines which contain a certain word, can that be done ?
>

Yeah, that can be done, but not with a dedicated object (save perhaps a 3rd party external).

A max only implementation would be this:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 46 58 28 9109513 input;
#P newex 96 143 27 9109513 > 0;
#P newex 96 164 28 9109513 sel 1;
#P newex 59 189 30 9109513 zl reg;
#P newex 79 79 27 9109513 t l l;
#P newex 59 211 26 9109513 print;
#P message 79 58 173 9109513 fishswim , fishjump , swimjump , bluefish;
#P newex 96 100 40 9109513 atoi;
#P newex 96 122 32 9109513 zl sub;
#P message 79 37 24 9109513 fish;
#P newex 138 100 40 9109513 atoi;
#P comment 14 37 59 9109513 criteria word;
#P connect 8 0 6 0;
#P connect 10 0 9 0;
#P connect 3 0 10 0;
#P connect 9 0 8 0;
#P connect 7 0 8 1;
#P connect 7 1 4 0;
#P connect 5 0 7 0;
#P connect 1 0 3 1;
#P connect 2 0 1 0;
#P connect 4 0 3 0;
#P window clipboard copycount 12;

Cheers,
Mattijs

#92038
Dec 30, 2006 at 7:39pm

Text is a wierd thing in Max, although I don’t want to say that it can’t be dealt with. I’ve always managed to do what I needed to do, but had to work at it more than I thought necessary. If you are good at JavaScript, you might want to use the [js] object to deal with strings, lists and the like. Max has objects with similar methods to those of other programming languages, but you will find that there are certain difficulties when formatting and analyzing strings, particularly when passing them between objects.
Case in point: try to add commas as subdivisions to numbers over 999. I am more than willing to admit to ignorance when I say that in the end I just gave up on Max and wrote a short routine in JavaScript. It seems that the problems arise in Max’s necessity to dynamically recognize what is a “symbol” as opposed to an “int” or “float”, and divide data into lists. This is certainly not a weakness, but rather a strength, but it makes it difficult when formatting and analyzing strings which are a bit long or complicated.
(I can see the outraged replies coming in to this post now… Believe me, if anyone out there has done enough with strings to prove me irrevocably wrong, I’ll buy them a coffee. Lets try with the example above.)

#92039
Dec 30, 2006 at 10:49pm

Quote: Dayton wrote on Sat, 30 December 2006 20:39
—————————————————-
Lets try with the example above.
—————————————————-

Like this?

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 46 187 44 9109513 zl slice 1;
#P newex 46 209 31 9109513 zl rev;
#P newex 46 100 31 9109513 zl rev;
#P newex 29 58 27 9109513 t b i;
#P newex 46 251 26 9109513 print;
#P newex 46 230 40 9109513 itoa;
#P newex 46 143 29 9109513 t l 44;
#P newex 46 166 40 9109513 zl group;
#P newex 46 79 40 9109513 atoi;
#P newex 46 121 38 9109513 zl iter 3;
#P number 29 41 67 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P connect 0 0 7 0;
#P connect 7 1 2 0;
#P connect 2 0 8 0;
#P connect 8 0 1 0;
#P connect 1 0 4 0;
#P fasten 7 0 3 0 34 164 51 164;
#P connect 4 1 3 0;
#P connect 4 0 3 0;
#P connect 3 0 10 0;
#P connect 10 1 9 0;
#P connect 9 0 5 0;
#P connect 5 0 6 0;
#P window clipboard copycount 11;

#92040
Dec 31, 2006 at 10:12am

Looks like I owe you a coffee.
So it’s all just a matter of converting strings into the realm of ASCII int values. Makes sense, but, as I wrote, a bit wierd.
Hats off; I wouldn’t have thought of that.

#92041
Dec 31, 2006 at 12:00pm

#92042
Dec 31, 2006 at 12:21pm

Quote: Dayton wrote on Sun, 31 December 2006 11:12
—————————————————-
> Looks like I owe you a coffee.
> So it’s all just a matter of converting strings into the realm of ASCII int values. Makes sense, but, as I wrote, a bit wierd.
> Hats off; I wouldn’t have thought of that.
—————————————————-

Thanks :)

Besides, I totally agree that handling strings is probably the weakest part of max where it comes to intuitivity.

Your example is not a standard operation, it’s more about juggling with data, where I don’t expect a very simple solution. More basic operations on the other hand, such as concatenating strings or simply passing a string with spaces properly from object to object, are not intuitive (to say the least) and can be a real pain for a new user.

As you said, this is due to the various overlapping data types and how they are implemented in the development kit (lists, messages, symbols, the anything() function). This thread beautifully illustrates the problem:

http://www.cycling74.com/forums/index.php?t=msg&goto=85025&rid=3579&S=fea9fc8a3dc7492d221e367708ba97ed

These choices have been made in the relatively ancient past and are probably very hard to roll back. What remains to be made, though, is a straight-forward explanation of the current situation and which objects to use in which specific case. I started working on such a guide but haven’t had time to finish it. If someone feels like picking up this project, let me know.

Mattijs

#92043

You must be logged in to reply to this topic.