Help in script logic

Post your questions and help other users.

Moderator: Martin

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Help in script logic

Post by MURTUMA » 09 Mar 2015 09:33

I was in impession that the else statement covers both if statements, but that seems not to be the case.

Is there a command to jump forward when the first if statement is true? Or is there a way to make the else statement cover both if statements?

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: Help in script logic

Post by Bushmills » 09 Mar 2015 10:02

let the braces { } surround the whole else-part, including your two if clauses, like
if (condition) {
true portion here
} else {
if (condition) {
stuff
}
if (condition) {
stuff
}
}

or, better:
simplify. consider to seperate dealing with each condition (charging, critical), as in (example):

status="not charging";
if (charging) status="charging";
if (critical) status+=", critical";

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Help in script logic

Post by MURTUMA » 10 Mar 2015 09:15

Thanks! Nerey used this solution in his script, but I didn't understood it from there. Now I got it.

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: Help in script logic

Post by Bushmills » 14 Mar 2015 10:25

As you don't seem to feel comfortable with the idea of simplifying your logic, please consider that doing so should also reduce power dissipation of your device.

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Help in script logic

Post by MURTUMA » 14 Mar 2015 14:08

Bushmills wrote:As you don't seem to feel comfortable with the idea of simplifying your logic
How did you come to that conclusion?
consider that doing so should also reduce power dissipation of your device.
True, but as the script(both original and nerey's) is already very short and simple, the advantage would be very slight and maybe unnoticeable.

I stated in the OP that I have everything working good, but there were just one thing I didn't understand, which is not the case anymore. Also, because the meaning of this thread was only to help me understand that logic flaw, this has served its purpose. Because of that, I didn't bother posting here all the diffenrent tests with the script I was making.

So far, I have nothing to add here anymore but I'll come back with more questions or info, if something relevant comes up. Thanks for everyone.

Post Reply