blockly else statement

Moderator: leecollings

Post Reply
nikos
Posts: 4
Joined: Wednesday 17 January 2018 16:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

blockly else statement

Post by nikos »

Hi all,

I am new here, so pls excuse me if I am asking something already answered (I have not found an answer yet).
So my question is why is the "else' statement missing from the "if" options? Is it implemented by some other means??
Its presence would save us from an awful lot of repetitions.
misfit
Posts: 18
Joined: Wednesday 29 November 2017 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: blockly else statement

Post by misfit »

You have that:
elseif.png
elseif.png (8.8 KiB) Viewed 4613 times
If you want to run statement if none of the 'else if' branch evaluates to true, then just put an always true condition (with a user variable) in a last 'else if' branch.
nikos
Posts: 4
Joined: Wednesday 17 January 2018 16:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: blockly else statement

Post by nikos »

Thanks misfit, that's a good idea to get around the lack of the else statement. But why is it missing from the Domoticz blockly?
Xztraz
Posts: 107
Joined: Tuesday 31 January 2017 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: blockly else statement

Post by Xztraz »

blockly else if is only used a a placeholder for multiple ifs. check the wiki out. quite explained there. http://www.domoticz.com/wiki/Blockly
There is some activity regarding "if else" if it's possible to make it a real else if.
User avatar
i3laze
Posts: 7
Joined: Thursday 26 July 2018 9:48
Target OS: Windows
Domoticz version:
Contact:

Re: blockly else statement

Post by i3laze »

misfit wrote: Sunday 21 January 2018 10:06 ..just put an always true condition (with a user variable) in a last 'else if' branch.
How can I get this ‘True’ block?
1=1? Example, plz.
mrf68

Re: blockly else statement

Post by mrf68 »

misfit wrote: Sunday 21 January 2018 10:06
If you want to run statement if none of the 'else if' branch evaluates to true, then just put an always true condition (with a user variable) in a last 'else if' branch.
I tried this (Event - Blockly - All):

Image

It doesn't work.

But the next one did (Event - Blockly - All):

Image

The second one confirms that the value of the variable is correct.

Try to be as simple as possible with blockly's. One if and one do. Need something else done? Create another. It also helps troubleshooting.

And if you definitely need the else if, why not use the same components and use "is not" instead of "is"?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest