Page 1 of 1

Decision Question

Posted: Sat Nov 30, 2013 8:14 pm
by acestu
Hi,

I am trying to determine the condition of ten variables in 1 decision but I don't think I am wording it correctly, I am using:



If
(Timer1Status = 0) && (Timer2Status = 0) && (Timer3Status = 0) && (Timer4Status = 0) && (Timer5Status = 0) && (Timer6Status = 0) && (Timer7Status = 0) && (Timer8Status = 0) && (Timer9Status = 0) && (Timer10Status = 0)

And basically what I am trying to say is,

Is the value of all these variables 0 ?


Is this the correct way to write this ?

thanks
Acestu

Re: Decision Question

Posted: Sat Nov 30, 2013 8:45 pm
by cobra1
That looks good to me :)

Re: Decision Question

Posted: Sat Nov 30, 2013 9:26 pm
by medelec35
That also looks good to me.

If you want to simplify your flowchart and use less icons you could considered using a a 10 element array instead of 10 individual variables.
I did an example of this within a Flowchart that can be found here:
http://www.matrixmultimedia.com/mmforum ... 413#p53464

You will be able to see using the array method enabled my to set up 255 different pass codes without having a load of different massive decision icons

Martin

Re: Decision Question

Posted: Sat Nov 30, 2013 9:29 pm
by acestu
Hi Cobra,

Thanks for confirming this, I guess my problem lies elsewhere.....

cheers
Acestu

Re: Decision Question

Posted: Sat Nov 30, 2013 9:32 pm
by acestu
Hi Martin,

This problem is to do with the Interrupt and Boost issue that you helped me with last week, I think I am going to have to post the chart for you to look at...

cheers
Acestu

Re: Decision Question

Posted: Sun Dec 01, 2013 11:52 pm
by Brendan
Hi Acestu.

I'm sure I'm missing the point (apologies in advance) but if specifically to check all values were zero then you could simply add all vars together and check for zero in the result.


All the best,

Brendan

Re: Decision Question

Posted: Mon Dec 02, 2013 8:59 am
by medelec35
Hi Brendan,
that's a good idea if the result is stored in an 16 bit int.
When the question was fist asked it was unknown want the value of variables were.
So if all variables were bytes you add the bytes when say Timer1Status = 1,Timer2Status = 255,Timer3Status = 0,Timer4Status = 0,Timer5Status = 0, Timer6Status = 0, (Timer7Status = 0, Timer8Status = 0, Timer9Status = 0, Timer10Status =0
and result was stored in a byte then result would be 0

So it would work so long as int and not byte is used.

I thought I would mention that in case Stu tries with a byte to store result.

In reality if each variable was either 0 or 255, then that would work with a result stored in byte or Int.


Martin

Re: Decision Question

Posted: Mon Dec 02, 2013 9:55 am
by JonnyW
Hi.

It would work if you orr the variables together: (A | B | C...) == 0

Upside is it is compact and produces less code. Downside is it is slower if the first value is zero (in which case && will not check any following values).

Cheers,

Jonny