Hello Folks -
I know there must be an easy way to do this, but I'm having terrible trouble figuring it out.
Is there an easy way to use a integer input to send a message out of an array of messages?
Ideally, it would look like this:
[bang] | [2] | [newcommand apple beats carrots cheeseburger] | [print]
and the output would be "carrots" (given 0 based indexing). Does this command already exist?
(Oh, and I'm pushing this into a GEM text object, so the screen would say "carrots" in some way).
I apologize if this is obvious, my head might be fatigued. select and route take a value but split it into a bunch of different directions. I want to go the other way....
Thanks for the time if anyone has a suggestion!!!
Fred Smith wrote:
Hello Folks -
I know there must be an easy way to do this, but I'm having terrible trouble figuring it out.
Is there an easy way to use a integer input to send a message out of an array of messages?
Ideally, it would look like this:
[bang] | [2] | [newcommand apple beats carrots cheeseburger] | [print]
and the output would be "carrots" (given 0 based indexing). Does this command already exist?
[bang] | [t b f] | | | [clear, adddollar $1< | | [blah blah< | | / | / [empty messagebox < |
********** or ****************
[bang] | [t b f] | | [blah blah< [- 1] | / [list split] | [$1< |
in case it is not clear, both the clear,adddollar on the top and the [blah blah< connect to the same object, and the $1 on the bottom is coming out of the middle inlet of the list split
Justin Glenn Smith wrote:
Fred Smith wrote:
Hello Folks -
I know there must be an easy way to do this, but I'm having terrible trouble figuring it out.
Is there an easy way to use a integer input to send a message out of an array of messages?
Ideally, it would look like this:
[bang] | [2] | [newcommand apple beats carrots cheeseburger] | [print]
and the output would be "carrots" (given 0 based indexing). Does this command already exist?
[bang] | [t b f] | | | [clear, adddollar $1< | | [blah blah< | | / | / [empty messagebox < |
********** or ****************
[bang] | [t b f] | | [blah blah< [- 1] | / [list split] | [$1< |
in case it is not clear, both the clear,adddollar on the top and the [blah blah< connect to the same object, and the $1 on the bottom is coming out of the middle inlet of the list split
I missed the float in both examples, imagine the [2] or whatever number is where the [bang] is now in each one.
2009/10/11 Justin Glenn Smith noisesmith@gmail.com
Justin Glenn Smith wrote:
I should really test this stuff before recommending on a mailing list
iknow this. the heat of the moment.. :-P
[2 ( <--
index number of list element to export (starting from 1!)
|
[t b f]
| \ [list apple beats carrots cheeseburger ( <-- your list
| X
[list ]
| [set text, adddollar $1(
| /
| /
| /
| /
|/
[ ( <--
empty message box
|
[text3d ]
ciao
on a related question: a controller is sending me lists of numbers, 20 at a time. I'd like to be able to store this list and later access it by index.
what's the neatest way to achieve this?
I'm a Noob, and not sure yet if I should be thinking about lists, tables, arrays or what...
tia
2009/10/11 Andy Wilson andy@lshift.net
on a related question: a controller is sending me lists of numbers, 20 at a time. I'd like to be able to store this list and later access it by index.
if you just need to store one list at a time you can just use the [list ] object. if you need to store more lists then [textfile ] is your friend.
alabala
On Sun, 11 Oct 2009, Andy Wilson wrote:
on a related question: a controller is sending me lists of numbers, 20 at a time. I'd like to be able to store this list and later access it by index. what's the neatest way to achieve this?
You can use a 1-dimensional array to store 2-dimensional data. For example, if you want keep a memory of the last 50 instants for which you have controller data, you can use an array of 1000 elements, and use [tabread] with the instant number times 20, plus the number of the element.
this assumes numbering the instants from 0 to 49 and the elements of an instant from 0 to 19. If you want to number things starting at 1, it gets complicated by an extra subtraction if you care about using all the array space you are reserving.
if you have several controllers, you can do something similar... add a 3rd axis to your data: the controller number. for example, with 4 controllers, use [tabread] with the instant number times 80, plus the controller number times 20, plus the number of the element.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801
which could look in pd code like this:
<your lists here>
|
[list prepend]\
|\__________\_ <-- make a bigger list
consisting of all your lists | [t l ] | | | [13 5 ( <-- set values for output here; | | this means index 13 from the fifth "list" __|___[t b l ] / | | / | [unpack ] [list ] | | | | ___[* 20] <-- list number * "list" length | [+ ] <-- and add to the index | | |__________[set, adddollar $1 ( [ ( <-- empty message box | |
<output>
ciao
Hi Fred,
The list-abs library has an object [list-idx] which might be useful. It's pretty easy to use.
Kind regards, Lorenzo.
Fred Smith wrote:
Hello Folks -
I know there must be an easy way to do this, but I'm having terrible trouble figuring it out.
Is there an easy way to use a integer input to send a message out of an array of messages?
Ideally, it would look like this:
[bang] | [2] | [newcommand apple beats carrots cheeseburger] | [print]
and the output would be "carrots" (given 0 based indexing). Does this command already exist?
(Oh, and I'm pushing this into a GEM text object, so the screen would say "carrots" in some way).
I apologize if this is obvious, my head might be fatigued. select and route take a value but split it into a bunch of different directions. I want to go the other way....
Thanks for the time if anyone has a suggestion!!!
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hey all -
I just wanted to thank you for all the great feedback - I apologize for the silence that followed. Real life got in the way of my experiments temporarily, but I'll soon be able to hop back on this stuff.
Thanks again! -fred
On Sun, Oct 11, 2009 at 7:11 AM, Lorenzo lsutton@libero.it wrote:
Hi Fred,
The list-abs library has an object [list-idx] which might be useful. It's pretty easy to use.
Kind regards, Lorenzo.
Fred Smith wrote:
Hello Folks -
I know there must be an easy way to do this, but I'm having terrible trouble figuring it out.
Is there an easy way to use a integer input to send a message out of an array of messages?
Ideally, it would look like this:
[bang] | [2] | [newcommand apple beats carrots cheeseburger] | [print]
and the output would be "carrots" (given 0 based indexing). Does this command already exist?
(Oh, and I'm pushing this into a GEM text object, so the screen would say "carrots" in some way).
I apologize if this is obvious, my head might be fatigued. select and route take a value but split it into a bunch of different directions. I want to go the other way....
Thanks for the time if anyone has a suggestion!!!
_______________________________________________Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list