Proper format for If statement with comparision

I need some help properly formatting this if statement (which compares the boolean Feed_Ready_Flag which must be true, Pump_TimeRemaining >= to 35 and <=44. If all those are true, it goes to the Feed_Prog, closes a relay momentarily; reset the Feed_Ready_Flag to false then continues on with the rest. This statement puts things in a loop and keeps going back to the Feed_Prog even though the feed ready flag was changed to false so im wondering if i have a mistake on this statement.

 void Feed_Ready_Check() {
  if (Feed_Ready_Flag = true && Pump_TimeRemaining >= 35 && Pump_TimeRemaining <= 44) { 
    Feed_Prog();
    } else {
    }
 }

= for assignment of a value
== for comparison between values

So do i need to change something? I need to ensure that all 3 variables are true.

== for comparison between values

What does your code use to test for equality between Feed_Ready_Flag and true true ?

if (Feed_Ready_Flag = true && Pump_TimeRemaining >= 35 && Pump_TimeRemaining <= 44)

UKHeliBob:
What does your code use to test for equality between Feed_Ready_Flag and true true ?

I'm not testing between Feed_Ready_Flag and true true. The below code sets the flag to true then if the other 2 are true then go to the Feed program. Im actually trying to test between these 3 with the if statement above. Do i need to use 2 if statements (1 for the feed flag and another for the pump remaining time range)?

void Feed_Ready_1 (){

Feed_Ready_Flag = true;
  Next_Feed_Flag = Feed_2_SP;
}

Actually maybe the order of precedence is off? Im gonna try this:

 void Feed_Ready_Check() {
  if (Feed_Ready_Flag = true && (Pump_TimeRemaining > 39 && Pump_TimeRemaining < 42)) { 
    Feed_Prog(); } 
  }

That still won't work because you're still doing an ASSIGN (=) to Feed_Ready_Flag and not a COMPARISON (==) with it.

Steve

Do you understand response #1 ?

.

i got it was actually a typo. I just couldnt fix it because of the silly 5 post rule. this is what it actually is:

void Feed_Ready_Check() {
  if (Feed_Ready_Flag = true && (Pump_TimeRemaining >= 39 && Pump_TimeRemaining <= 42)) {
    Feed_Prog(); }
  }

Feed_Ready_Flag = trueWrong

ok that was still the typo. In either case, i used integers instead of Boolean and added the conditions for a test then proceed to the feed program. works perfect. Im not sure if there is an issue with boolean but they print as 0 and 1 not true and false. im rolling with it. thanks.

Im not sure if there is an issue with boolean but they print as 0 and 1 not true and false

No issue there. In practice 0 is false and any other value is true but booleans will always be either 0 (false) or 1 (true)

You do not actually have to do a comparison when using a boolean

if (Feed_Ready_Flag && (Pump_TimeRemaining >= 39 && Pump_TimeRemaining <= 42))

Would work just as well

UKHeliBob:

if (Feed_Ready_Flag && (Pump_TimeRemaining >= 39 && Pump_TimeRemaining <= 42))

Would work just as well

That looks cleaner, ill give that a shot. thanks for the assistance.

It would read even better if you named the boolean variable feedReady. Naming variables can sometimes be a subtle business.