Multiple && checking

why? because you want it to check everything, regardless of whether or not everything else comesback true.

There are more than 300 if statements and cases in the code.

This concerns me - especially if they're all in one block of logic.

roosterqmoney:
why? because you want it to check everything, regardless of whether or not everything else comesback true.

if one of the statement in if will be false then how it will check other statements ? if its checking from left to right if one of the statement will be false then its done if is not true anymore and will continue comparing with other statements in other switchs and ifs.

if one statement is false, then the code inside the if will not execute, therefore who cares wether the other statements are true?

surepic:
if one of the statement in if will be false then how it will check other statements ?

I want to know if we're on the same page. If any of the comparisons are false, none of the other expressions should be checked. It would be a silly waste of CPU time.

lastchancename:
This concerns me - especially if they're all in one block of logic.

but code is working. no problems so far I was warned that I might have some problems with long ifs and switches but whats the difference between 1 if and 1000 ? or switch with 1000 cases ? in books that I read there are no warnings about how many ifs is good or bad to use unless you can understand your code.

or if example available please.

think simple ifs are getting too complicated now cos I cant understand now which post misleaded people.

if 1 condition if && is not true then how it will check other condition? whole if will not be true then, so whats wrong ?

if 1 condition if && is true then it will start checking second statement because there are in braces so first condition is checked it is true which means if is still good it is going to the second statement now is condition true or false if it is true again is going further from left to right but if its not true then again whole if is no longer good and its terminating that particular if and looking what else is after curly braces then it sees another else if and whole process goes over again.

Sometimes beginners code a huge list of if statements when a table lookup or an iteration will do it in a few lines.

surepic:
think simple ifs are getting too complicated now cos I cant understand now which post misleaded people.

if 1 condition if && is not true then how it will check other condition? whole if will not be true then, so whats wrong ?

if 1 condition if && is true then it will start checking second statement because there are in braces so first condition is checked it is true which means if is still good it is going to the second statement now is condition true or false if it is true again is going further from left to right but if its not true then again whole if is no longer good and its terminating that particular if and looking what else is after curly braces then it sees another else if and whole process goes over again.

If you have a question, can you isolate it and ask it succinctly as one question?

database is being made on the go and for me now is very easy to add extra if or case in switch. am not running out of memory yet. making table will not be easy task cos of huge database :))) every time Im looking at it Im getting very tired .

there is no question in this post. :slight_smile:

surepic:
there is no question in this post. :slight_smile:

Ok. The forum name is "programming questions", so...

Posts #26 and #29 are contradicting #25 - also by the OP...
Why not post ALL your existing code (in tags) - and we may see a method to help you optimise and simplify your code.

No promises - and maybe you don't want it, but it would be neat to see hundreds of if()s lined up together.

aarg:
Ok. The forum name is "programming questions", so...

that was "reply without question" to the post before that one.
like this is reply to the post in quotes :))))

lastchancename:
Posts #26 and #29 are contradicting #25 - also by the OP...
Why not post ALL your existing code (in tags) - and we may see a method to help you optimise and simplify your code.

No promises - and maybe you don't want it, but it would be neat to see hundreds of if()s lined up together.

As there are members who are very picky with the structure of the threads. guess I have to make another topic for that.

joking....

Doh - no I think I typed "aa" because I had just typed "++".

surepic:
There are more than 300 if statements and cases in the code.

You probably need to be using arrays rather than doing this.

Example?

It may help if you post your complete code in </> tags... then we might be inclined to illustrate how better techniques can be applied - if they're relevant. Maybe your 300 ifs are already the best approach...

Just guessing is rarely the best approach to efficient code structure and development.

surepic:
Example?

https://forum.arduino.cc/index.php?topic=498520.0

surepic:
database is being made on the go

Which database?