Page 2 of 2

Re: Blocky script doesn't work like expected...

Posted: Wednesday 29 March 2017 23:17
by Nautilus
Lebo2d9 wrote:Hi,
I have also a strange behavior with a nested if else-if
The 2 write to log are always executed.
Is this normal or have I done soemthing wrong?
K3rryBlue wrote:Seems that the structure is correct. Both conditions if vakanie=off and else if vakanie=on are different, it should never execute both. In either case if one is true the other is always wrong. Unless "on/off" is not valid for this switch.
The issue is most probably the simple (yet disappointing) fact that nested if's do not work in Domoticz's Blockly implementation (as it has been covered in numerous of these threads discussing various Blockly issues in Domoticz :D). If you write the logic with just one "if - else" then it should work (i.e. add the the first condition to both of the nested conditions to remove the first condition fully)...

Re: Blocky script doesn't work like expected...

Posted: Thursday 30 March 2017 7:23
by Lebo2d9
Hi Nautilus,

I have solved it this way

Image

Thx for the replies

Koen

Re: Blocky script doesn't work like expected...

Posted: Friday 30 June 2017 20:00
by Kubiekdriehoekje
Like Spitfire and others stated before else-if logic is broken:

The following example is how it should work:
ifelseifelseif.png
ifelseifelseif.png (34.75 KiB) Viewed 1056 times

Code: Select all

PRE:
	x=0
	y=0

Code: Select all

RUN 1:
	x == 0 && y == 0
	x -> 1
	
RUN 2:
	x == 1 && y == 0
	y -> 1
	
RUN 3:
	x == 1 && y == 1
	x -> 0
	y -> 0
But instead it behaves like this example:
ififif.png
ififif.png (37.24 KiB) Viewed 1056 times

Code: Select all

PRE:
	x=0
	y=0

Code: Select all

RUN 1:
	x == 0 && y == 0
	x -> 1
	x == 1 && y == 0
	y -> 1	
	x == 1 && y == 1
	x -> 0
	y -> 0

Re: Blocky script doesn't work like expected...

Posted: Wednesday 02 January 2019 11:37
by tjerk
I'm facing the same issue/bug with nested if statements as described in viewtopic.php?f=62&t=16455#p126119
After reading multiple threads (viewtopic.php?f=62&t=16271) I'm not using nested blocks anymore. Would be nice to have this feature in the future ;-)
Example which triggers both error logs:
Example nested blog with bug.png
Example nested blog with bug.png (90.49 KiB) Viewed 459 times