Page 1 of 1

Posted: 06 Aug 2007, 13:01
by LevraiBernardo
Hello
I'm wondering if it's possible to get the number of items in a list (or a combo). Any suggestion ?

Posted: 06 Aug 2007, 14:38
by bsork
There's no way that I know of that will give you the number of items without jumping within the list, but it's possible to retrieve the number and jump back to whatever the current entry is:

Assuming a Button is used to trigger the process, you'll need two each of PassEventFlow, Variable and WaitOneCycle modules. Plus of course the Combo or List:

1) Button.Out > WaitOneCycle[1] > PassEventFlow[1].Pass.
2) Set PassEventFlow[1].In to a number higher than the number of entries will ever be.
3) PassEventFlow[1].Out > Combo.List
4) Button.Out > WaitOneCycle[1] > WaitOneCycle[2] > PassEventFlow[2].Pass.
5) PassEventFlow[2].Out > Combo.List
6) Button.Out > Variable[1].Affect
7) Combo.List > Variable[1].In
8) Variable[1].Out > PassEventFlow[2].In
9) Button.Out > WaitOneCycle[1] > Variable[2].Affect
10) Combo.List > Variable[2].In

Variable[1].Out will hold the original entry (remember that counting starts at 0), while Variable[2].Out holds the number of entries.

There's probably other ways of doing this, but this is the simplest way I could think of right now.

Posted: 07 Aug 2007, 08:22
by senso
Yes actually, there is no way to retrieve the length of a list, except the solution posted by Bsork.
It's a leak of Usine, I'll try to find something simple like an outlet.

Posted: 07 Aug 2007, 12:24
by Vincent
Yes, Olivier, a "len" outlet would be sometimes helpful, specially in the sampler (for the file list). That would allow special tricks.

Posted: 07 Aug 2007, 13:43
by LevraiBernardo
I agree with Vincent. It would be great, Senso.
Anyway, many thanks to Bsork. Incredible, but that works. (Now I understand why it's called Usine ;).

Posted: 07 Aug 2007, 14:29
by bsork
Glad to be of help!

I too agree with the len outlet idea. In fact, by coincidence I yesterday tried to find a good way to automate a saving process with a sampler and a preset manager in a patch, and a len outlet would make that easier.

(I think I'll end up not doing the automating thing anyway. That is however not because of a missing outlet.)

Posted: 07 Aug 2007, 21:28
by senso
ok,ok!
I'll implement some "list length functions" very soon.

Posted: 07 Aug 2007, 22:21
by LevraiBernardo
It's so good to feel understood... Thank you, Mr Senso.