ID:163149
 
Is there any better way todo the following then how I have done it?

if(Action == ">=")
if(FirstVar >= SecondVar){Then = 1;Else = 0}
else{Then = 0;Else = 1}
if(Action == "<=")
if(FirstVar <= SecondVar){Then = 1;Else = 0}
else{Then = 0;Else = 1}
if(Action == ">")
if(FirstVar > SecondVar){Then = 1;Else = 0}
else{Then = 0;Else = 1}
if(Action == "<")
if(FirstVar < SecondVar){Then = 1;Else = 0}
else{Then = 0;Else = 1}
if(Action == "==")
if(FirstVar == SecondVar){Then = 1;Else = 0}
else{Then = 0;Else = 1}
if(Action == "!=")
if(FirstVar != SecondVar){Then = 1;Else = 0}
else{Then = 0;Else = 1}


Thanks!
Firstly, why do you need a 'then' and an 'else' variable? Won't else always be equivalent to !then?

Furthermore, I suggest you look into 'switch()'.
In response to Jp
Jp wrote:
Firstly, why do you need a 'then' and an 'else' variable? Won't else always be equivalent to !then?

Furthermore, I suggest you look into 'switch()'.
switch(Action)
if(">=")
if(FirstVar >= SecondVar){Then = 1;Else = 0;continue}
Then = 0;Else = 0
if("<=")
if(FirstVar <= SecondVar){Then = 1;Else = 0;continue}
Then = 0;Else = 0
if(">")
if(FirstVar > SecondVar){Then = 1;Else = 0;continue}
Then = 0;Else = 0
if("<")
if(FirstVar < SecondVar){Then = 1;Else = 0;continue}
Then = 0;Else = 0
if("==")
if(FirstVar == SecondVar){Then = 1;Else = 0;continue}
Then = 0;Else = 0
if("!=")
if(FirstVar != SecondVar){Then = 1;Else = 0;continue}
Then = 0;Else = 0

/dm>

Because Then and Else can be equal to numbers larger then 1, and the value does matter. Unfortunatly the variable is needed outside of iteration loop, so i can not simply redefine the variables at the begining of the loop.