Welcome to %s forums

BrainModular Users Forum

Login Register

How much in this list ?

I need help on a Patch
Post Reply
LevraiBernardo
Site Admin
Posts: 110
Contact:

Unread post by LevraiBernardo » 06 Aug 2007, 13:01

Hello
I'm wondering if it's possible to get the number of items in a list (or a combo). Any suggestion ?

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 06 Aug 2007, 14:38

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.
Bjørn S

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 07 Aug 2007, 08:22

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.

User avatar
Vincent
Member
Posts: 317
Location: PACA
Contact:

Unread post by Vincent » 07 Aug 2007, 12:24

Yes, Olivier, a "len" outlet would be sometimes helpful, specially in the sampler (for the file list). That would allow special tricks.
vincent michel
composer & novelist

LevraiBernardo
Site Admin
Posts: 110
Contact:

Unread post by LevraiBernardo » 07 Aug 2007, 13:43

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 ;).

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 07 Aug 2007, 14:29

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.)
Bjørn S

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 07 Aug 2007, 21:28

ok,ok!
I'll implement some "list length functions" very soon.

LevraiBernardo
Site Admin
Posts: 110
Contact:

Unread post by LevraiBernardo » 07 Aug 2007, 22:21

It's so good to feel understood... Thank you, Mr Senso.

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests