Forums > MaxMSP

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

Nov 03 2011 | 8:20 pm

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 ?

Nov 03 2011 | 8:30 pm

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

Nov 03 2011 | 10:55 pm

Like this?

-- Pasted Max Patch, click to expand. --

Nov 04 2011 | 9:22 am

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.

  1. nomM.txt
Nov 04 2011 | 10:06 am

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 :-)

-- Pasted Max Patch, click to expand. --

  1. nomM.txt
Nov 04 2011 | 10:46 am

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

  1. names.txt
Nov 04 2011 | 10:49 am

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;

Nov 04 2011 | 11:01 am

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

-- Pasted Max Patch, click to expand. --

Nov 04 2011 | 1:44 pm

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 ?

Nov 04 2011 | 2:20 pm

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

-- Pasted Max Patch, click to expand. --

Nov 04 2011 | 6:15 pm

A tiny improvement to Luke’s solution:

-- Pasted Max Patch, click to expand. --

Nov 04 2011 | 8:25 pm

Haha, always room for improvement! :)

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

Forums > MaxMSP