While that is mostly true, it isn't always so. Sometimes, you really need to know you've created a new msg object. Also, you sometimes need more than 1 msg object.
Installed my contribution from my Github repository, to make sure I have the same version as you.
Tried both your examples and it works fine here...
No clue what is going wrong. I had yesterday also a few issues after I changed the structure of the json blocks (since the workspace kept some info from the original structure). Could you please do the following:
Refresh your browser window
Remove the Blockly node from your flow
Add a new Blockly node for your test.
If it still doesn't work, please send a screenshot of the 'generated Javascript' tabsheet, and an export of your Blockly node flow ...
P.S. Good proposal to have a 'send msg' block without msg input, since that would be lot of easier to use. That is the kind of feedback I was hoping for ... But as Julian already mentioned you sometimes need to specify which message you want to send. For example when you want to resend every input message 5 times:
In this case it is best practice to clone the input message, before sending it. Otherwise the next node in the flow would receive 5 times the same message, which will result in conflicts when that node starts editing the content of every message ...
Or you might simply send your own object so please allow for that.
I do think this is a great addon for Node-RED and I hope that it gets promoted. I can see this being especially useful in education environments. Node-RED and Blockly would make a great next step up from Scratch. Currently students seem to have to make a leap from Scratch to Python and I think that loses a lot of people.
Thanks for the compliment. Makes me forget that I have been debugging very late last evening to fix Simon's issue But indeed I also planned to promote this contribution with some 'eductational' people, which I know are using Node-Red with their students...
Is this what you mean??
P.S. All credits for these JSON blocks go to Mark Friedman ...
How about changing the labelling on the block so that it just says "send" and not "send msg"?
(as the word msg is basically a reserved word in Node-RED)
Yep, that is something I have been asking myself. Could be "send" or perhaps even better "send object", since you can only send an object (and e.g. not a number or a string ...). But indeed not "send msg".
We talk about sending messages not objects. Yes a message needs to be an object rather than other types, but I'd suggest either just send or send message.
Does blockly do any type checking so it can only allow joining a block that outputs an object to the send block?
Every block in Blockly 'can' do type checking, and most of the time it will be used otherwise you will run into troubles (see below). Good that you mention it, because seems that I forgot it on the node_send block. Added it now on Github:
With check (e.g. 'Object') you can only link other blocks to it, whose output is an 'Object'. When you try to link another type to it, you will notice that you cannot drop the block at that location:
I will need to have a label at the input of the node_send block (to explain what the input needs to be), so then it should be like below ?
The end of a function uses return(msg), (or return(null) etc) but if you need to send something asynchronously you use node.send(msg). So it depends how you want to āhelpā students from blockly to js functions.
PS Iād also vote for just āSendā ( with type checking on )
Another question, and then I'm off to do some parental stuff with my boys ...
At the bottom you can change the number of output ports, and in the send-block you can specify to which of those outputs the message/object needs to be send.
However the number of outputs (at the bottom) can be set to a value lower than used in the send-blocks. Or in the send blocks an output number can be specified which is higher than the number of available outputs. In both cases you try to send to an unexisting output.
In this case I generate an error in the log, since I cannot send something:
Is this a good solution, or could I do better?
Thanks !