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

Nov 3, 2011 at 8:20pm

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

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 ?

#59787
Nov 3, 2011 at 8:30pm

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

#215177
Nov 3, 2011 at 10:55pm

Like this?

– Pasted Max Patch, click to expand. –
#215178
Nov 4, 2011 at 9:22am

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.

Attachments:
  1. nomM.txt
#215179
Nov 4, 2011 at 10:06am

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. –
Attachments:
  1. nomM.txt
#215180
Nov 4, 2011 at 10:46am

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

Attachments:
  1. names.txt
#215181
Nov 4, 2011 at 10:49am

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;

#215182
Nov 4, 2011 at 11:01am

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

– Pasted Max Patch, click to expand. –
#215183
Nov 4, 2011 at 1:44pm

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 ?

#215184
Nov 4, 2011 at 2:20pm

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

– Pasted Max Patch, click to expand. –
#215185
Nov 4, 2011 at 6:15pm

A tiny improvement to Luke’s solution:

– Pasted Max Patch, click to expand. –
#215186
Nov 4, 2011 at 8:25pm

Haha, always room for improvement! :)

#215187

You must be logged in to reply to this topic.