automatically fill a coll with the right syntax from a message or text file ?

Stephane Morisse's icon

I'm making an 'indian name generator' randomly choosing from three lists (adj1, name, adj2) and I'm looking for a way of filling the three 'coll' objects I use to pick the random elements from, but without having to type '1, sequoia; 2, ...;). So I thought maybe this could be possible from a text file or message because my lists are about 300 words each for now. Any smart solution ?

Chris Muir's icon

This doesn't sound too hard. Post an example file.

Luke Woodbury's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Like this?

Stephane Morisse's icon

To Chris : here's a short sample. The patch above doesn't work, I'm now trying out figure out why. I think there are missing arguments for the counter and a way to send bangs to it to make it add the index.

2825.nomM.txt
txt
Stephane Morisse's icon
Max Patch
Copy patch and select New From Clipboard in Max.

To Chris : ok, so now I've got this which seems smart to me (I'm a max beginner) EXCEPT that the first element of the text file is indexed as the last in the 'coll'. Don't understand why for now...
I add a new text file as my patch works (I imagine so but maybe I'm wrong) because each word is a on a different line. Is there a way to do the same with just spaces between words in the list ?
btw, just noticed your name in the uzi help file, so I guess you're the one to help me :-)

2826.nomM.txt
txt
Luke Woodbury's icon

Should have said, text file needs to have a name on each line, as attached. Should work perfectly!

2827.names.txt
txt
Luke Woodbury's icon

Just used your second text file with it and get this in my coll:

0, Obus;
1, Opossum;
2, Ovidé;
3, Ovipare;
4, Pamphlet;
5, Panorama;
6, Paradoxe;
7, Parasite;
8, Parfum;
9, Passe-temps;
10, Pastiche;
11, Pélerin;
12, Pensif;
13, Pensum;
14, Pépin;
15, Périmètre;
16, Perroquet;
17, Persifleur;
18, Pervers;
19, Pétoncle;

Luke Woodbury's icon
Max Patch
Copy patch and select New From Clipboard in Max.

And here's one that works with the names with just spaces between as in your first post:

Stephane Morisse's icon

Sorry Luke, your patch works, it's just that I had built mine besides sharing the same coll argument, hence the strange results I got as the two contents got mixed up. Now I've got your solution and mine, are there practical differences between the two ?

Luke Woodbury's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Well, the top part of your patch is redundant really, have a look here:

Chris Muir's icon
Max Patch
Copy patch and select New From Clipboard in Max.

A tiny improvement to Luke's solution:

Luke Woodbury's icon

Haha, always room for improvement! :)