Blockly nested if?
Moderator: leecollings
-
- Posts: 6
- Joined: Wednesday 03 February 2016 23:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Blockly nested if?
Is it possible to make nested if statements in Blockly? I'm using 2.4384 and can't get those green if-boxes togehter...
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Blockly nested if?
You need to use the AND/OR blocks, maybe together with a if/else if block.
The AND/OR blocks can be stacked.
Or, try scripting lua, php, bash... Way more flexible.
The AND/OR blocks can be stacked.
Or, try scripting lua, php, bash... Way more flexible.
-
- Posts: 6
- Joined: Wednesday 03 February 2016 23:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Blockly nested if?
Thanks, got it working in LUA. It wasn't so hard to at all.
-
- Posts: 2
- Joined: Friday 17 December 2021 21:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Blockly nested if?
I've figured out how to do this in Blockly, for the 2nd time now. (I forgot, and figured it out again).
1. Select 'Control' from the LH Blockly constructs menu
2. Choose the 'If... Do...' option with the little blue '+' sign in the top LH corner
3. Click on that little blue plus sign to show the 'else if' options.
4. In the pop-up menu that appears, drag an 'else if' from the LHS of the pop-up menu into the mouth of the 'if' statement on the RHS.
5. Keep dragging more 'else if' blocks onto the 'if' statement in the pop-up menu - you should be able to create nested 'if... else if... else if... else if...' to your heart's content.
6. Click the blue '-' icon on the 'if... else if' statement in your code canvas to hide the pop-up menu. You're done!
To get rid of 'else if' clauses from your 'if... else if' statement:
1. On the canvas, open up that pop-up menu again from the little blue '+' icon
2. Drag unwanted 'else if' clauses from the RHS of the pop-up menu to the LHS. Removing them from the bottom up causes just one clause to disappear, whereas dragging the top 'else if' causes them ALL to disappear, and leave you with just an 'if' statement.
BTW, I have tried a couple of times in the past to do away with my Blockly scripts and convert to using a proper scripting language but it looked like an inscrutable minefield, so I gave up!
1. Select 'Control' from the LH Blockly constructs menu
2. Choose the 'If... Do...' option with the little blue '+' sign in the top LH corner
3. Click on that little blue plus sign to show the 'else if' options.
4. In the pop-up menu that appears, drag an 'else if' from the LHS of the pop-up menu into the mouth of the 'if' statement on the RHS.
5. Keep dragging more 'else if' blocks onto the 'if' statement in the pop-up menu - you should be able to create nested 'if... else if... else if... else if...' to your heart's content.
6. Click the blue '-' icon on the 'if... else if' statement in your code canvas to hide the pop-up menu. You're done!
To get rid of 'else if' clauses from your 'if... else if' statement:
1. On the canvas, open up that pop-up menu again from the little blue '+' icon
2. Drag unwanted 'else if' clauses from the RHS of the pop-up menu to the LHS. Removing them from the bottom up causes just one clause to disappear, whereas dragging the top 'else if' causes them ALL to disappear, and leave you with just an 'if' statement.
BTW, I have tried a couple of times in the past to do away with my Blockly scripts and convert to using a proper scripting language but it looked like an inscrutable minefield, so I gave up!
Who is online
Users browsing this forum: No registered users and 0 guests