I'd be happy if the node worked like that but it doesn't at the moment
I wouldn't call it a bug - it's just not been programmed to behave that way
I'd be happy if the node worked like that but it doesn't at the moment
I wouldn't call it a bug - it's just not been programmed to behave that way
I'm confused - it works for me.
If I click on "ccc" it goes to "debug 60", which is the otherwise.
[{"id":"d618726bede89c3e","type":"inject","z":"3859418dcecf022c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"aaa","payloadType":"str","x":330,"y":80,"wires":[["1ed873439f089a73"]]},{"id":"1ed873439f089a73","type":"switch","z":"3859418dcecf022c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"else"},{"t":"cont","v":"aaa","vt":"str"},{"t":"cont","v":"bbb","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":530,"y":120,"wires":[["8938789f521e0e3f"],["d59ddd2155f68c8f"],["ab5f960a912e47ae"]]},{"id":"d59ddd2155f68c8f","type":"debug","z":"3859418dcecf022c","name":"debug 58","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":740,"y":80,"wires":[]},{"id":"ab5f960a912e47ae","type":"debug","z":"3859418dcecf022c","name":"debug 59","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":740,"y":120,"wires":[]},{"id":"8938789f521e0e3f","type":"debug","z":"3859418dcecf022c","name":"debug 60","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":740,"y":160,"wires":[]},{"id":"c7276c42f343c2fd","type":"inject","z":"3859418dcecf022c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"bbb","payloadType":"str","x":330,"y":120,"wires":[["1ed873439f089a73"]]},{"id":"fa3bd97aa1605eb6","type":"inject","z":"3859418dcecf022c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ccc","payloadType":"str","x":330,"y":160,"wires":[["1ed873439f089a73"]]}]
And "aaa" and "bbb" go to the expected outputs. Maybe it's the gin.
Running on 3.0.0. Could I be so bold as to suggest it's because I added the "otherwise" last and then dragged it first? That would be bad.
I think so
When you say
Define "expected"
I "want" aaa only to go to output 2 (debug 58)
Not outputs 2 AND 1
And i think crossing the wires in your example doesn't lend clarity
The impact of the gin is I tried changing from "stopping after first match" to "checking all rules". That doesn't work, and that's what I posted. If you change to "stopping after first match" it works for me. Time for another gin.
STOP!!!
When I change to stopping after 1st match, then all that happens is that all inputs get routed to output 1 (debug 60)
If this really doesn't happen to you then what is the number of the multiverse your living in so I can move there
Yeah ok. Time to stop the gin. It's nighttime here, so it's all above board. Except for my logic of course.
Well, if I request Otherwise
then to me that means if it doesn't match anything else
.
Well yes but it requires looking ahead, down the list, to see if would be true
Software doesn't normally behave that way
Letting it work if it was put at the top would be a great solution to the crossed wires issue but I totally understand why it doesn't at the moment
you are correct - the otherwise is just the catchall bucket at the end of the list.. just like you can't put the else clause first in an if then else statement.
Well you can parse the syntax tree in any manner you wish - it's just that no text languages do
But nothing intrinsically wrong with saying
If all else fails {
DoThis
} else if (Sky ==== blue) {
GoForPicnic
} else if (Sky ==== grey) {
ReadABook
}
Arguably, if Otherwise must always go at the end of the list then one should not be able to put it elsewhere.
Not even arguably, arguably
It would be really nice if it pinned itself to the last entry.
the ability to re-order was added well after the original, so yes maybe. The original idea was to try to make confg panels "readable" like a sentence - eg the udp input node - Listen for udp messages on port abc using ipv4 and output a string... over time that was untenable and has mostly been dropped, but that's where "otherwise" came from (and why it should be last).
em- no it wouldn't - it would be nice it it worked at the top as well as the bottom
If it was at the top I think the label would need to change ( eg as you suggested - if all else fails) but yes you will need to handle the out of order execution issues. Somewhat overkill to fix a wire crossing imho but the PR will be interesting
I'm making progress on the PR
Don't anyone help me - I'm having "fun" trying to do it
In the meantime, over in Snap!, we now have an "If All Else Fails" construct
The revolution has started
As written that really doesnât parse in my brain but then again I donât use scratch either. :-). Have fun
OK - proof of concept
This is in a separate dev instance on my Windows machine with modified switch node with some node.warn debugging to show what's happening
So, if you click on a
If b is pressed, it's processed the same as a but output goes to debug 3 of course.
If c is pressed then we get
If the switch is arranged with otherwise as the last rule, then output goes to debug 3 as normal without the onward array being manipulated at all
looks like good progress...
Just checking - as we do allow checking all rules... what would be the consequence of putting the otherwise in position 2 ? Currently as it's expected to be the end of the sequence it would get evaluated compared to previous rules and output appropriately... and then proceed to the next rules (3). I suspect now it would do the opposite and be tested compared to the later rules.