Page 1 of 1

boolean switch help :)

Posted: 13 Jan 2015, 15:36
by hgoodsir
hi all, happy newyear

I have been trying to create a boolean switch and have created this using c# node
it works but very long and seems a bad way write are there any suggestion how to write this better I need to
have 20 booleans. Many thanks

switch(Input)
{
case 1:
PAPER1 = true;
PAPER2 = false;
PAPER3 = false;
PAPER4 = false;
PAPER5 = false;
PAPER6 = false;
PAPER7 = false;
PAPER8 = false;
PAPER9 = false;
PAPER10= false;
PAPER11= false;
PAPER12= false;


break;
case 2:
PAPER1 = true;
PAPER2 = true;
PAPER3 = false;
PAPER4 = false;
PAPER5 = false;
PAPER6 = false;
PAPER7 = false;
PAPER8 = false;
PAPER9 = false;
PAPER10 = false;
PAPER11 = false;
PAPER12 = false;

break;
case 3:
PAPER1 = true;
PAPER2 = true;
PAPER3 = true;
PAPER4 = false;
PAPER5 = false;
PAPER6 = false;
PAPER7 = false;
PAPER8 = false;
PAPER9 = false;
PAPER10 = false;
PAPER11 = false;
PAPER12 = false;

break;
case 4:
PAPER1 = true;
PAPER2 = true;
PAPER3 = true;
PAPER4 = true;
PAPER5 = false;
PAPER6 = false;
PAPER7 = false;
PAPER8 = false;
PAPER9 = false;
PAPER10 = false;
PAPER11 = false;
PAPER12 = false;

break;
case 5:
PAPER1 = true;
PAPER2 = true;
PAPER3 = true;
PAPER4 = true;
PAPER5 = true;
PAPER6 = false;
PAPER7 = false;
PAPER8 = false;
PAPER9 = false;
PAPER10 = false;
PAPER11 = false;
PAPER12 = false;

break;
case 6:
PAPER1 = true;
PAPER2 = true;
PAPER3 = true;
PAPER4 = true;
PAPER5 = true;
PAPER6 = true;
PAPER7 = false;
PAPER8 = false;
PAPER9 = false;
PAPER10 = false;
PAPER11 = false;
PAPER12 = false;

break;
case 7:
PAPER1 = true;
PAPER2 = true;
PAPER3 = true;
PAPER4 = true;
PAPER5 = true;
PAPER6 = true;
PAPER7 = true;
PAPER8 = false;
PAPER9 = false;
PAPER10 = false;
PAPER11 = false;
PAPER12 = false;

break;
case 8:
PAPER1 = true;
PAPER2 = true;
PAPER3 = true;
PAPER4 = true;
PAPER5 = true;
PAPER6 = true;
PAPER7 = true;
PAPER8 = true;
PAPER9 = false;
PAPER10 = false;
PAPER11 = false;
PAPER12 = false;

break;
case 9:
PAPER1 = true;
PAPER2 = true;
PAPER3 = true;
PAPER4 = true;
PAPER5 = true;
PAPER6 = true;
PAPER7 = true;
PAPER8 = true;
PAPER9 = true;
PAPER10 = false;
PAPER11 = false;
PAPER12 = false;

break;
case 10:
PAPER1 = true;
PAPER2 = true;
PAPER3 = true;
PAPER4 = true;
PAPER5 = true;
PAPER6 = true;
PAPER7 = true;
PAPER8 = true;
PAPER9 = true;
PAPER10 = true;
PAPER11 = false;
PAPER12 = false;

break;
case 11:
PAPER1 = true;
PAPER2 = true;
PAPER3 = true;
PAPER4 = true;
PAPER5 = true;
PAPER6 = true;
PAPER7 = true;
PAPER8 = true;
PAPER9 = true;
PAPER10 = true;
PAPER11 = true;
PAPER12 = false;

break;
case 12:
PAPER1 = true;
PAPER2 = true;
PAPER3 = true;
PAPER4 = true;
PAPER5 = true;
PAPER6 = true;
PAPER7 = true;
PAPER8 = true;
PAPER9 = true;
PAPER10 = true;
PAPER11 = true;
PAPER12 = true;

break;
default: OFF();
break;

Re: boolean switch help :)

Posted: 13 Jan 2015, 16:19
by lerou
Hi,

depends a bit on what you're planning to do with those output bools. Here are three examples using int expressions, containers or a script with a bool array. Maybe one of those does what you want. Try not to use the script version if you need to copy it a lot.

cheers,
rou

Re: boolean switch help :)

Posted: 13 Jan 2015, 23:50
by hgoodsir
Many thanks rou, this helped me create what i needed which was like the switch node but inverted :)
thanks again.

Re: boolean switch help :)

Posted: 14 Jan 2015, 09:04
by Daniel Willer
The best and simplest waz to do it is using a ValueDispatcher node.

Regards
Daniel

Re: boolean switch help :)

Posted: 14 Jan 2015, 12:20
by hgoodsir
Hi Daniel,
thanks :) I posted in V4 by mistake but the place i'm at they are using ventuz 3 I wish they upgraded.

Re: boolean switch help :)

Posted: 14 Jan 2015, 13:43
by Daniel Willer
Ok I move the topic to V3.

Re: boolean switch help :)

Posted: 14 Jan 2015, 13:47
by lerou
He wanted all outputs i with i <= n to be true, the rest to be false. I don't think the dispatcher can do that, can it?

cheers,
rou

Re: boolean switch help :)

Posted: 07 Mar 2016, 09:34
by amarisJones
I have been concerned about this topic and have been looking for answers. Hoping to find the best solution, we look forward to your sharing. Thank you.