You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Blockly
I am developing a generator in Blockly for a custom language. I am using the function Blockly.MyLanguage.statementToCode( block, 'TheNameOfInput' ). The problem is that I can only use this function for one block. However I want to get the code for every block in the input 'TheNameOfInput'. In what way can I access the next block (eventually every block) in the same input with the function statementToCode()?
Kind regards,
Julian
Neil Fraser
unread,
Sep 27, 2021, 1:57:29 AM9/27/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Blockly
Generally each block will generate its own code, then call the generator on any next block. Thus calling Blockly.MyLanguage.statementToCode( block, 'TheNameOfInput' ) will return the output of the entire stack, not just the one block at the top.
The mechanism for this is Blockly.Generator.prototype.blockToCode which calls the generator's scrub_ function (here's JavaScript's scrub_ as an example). I'd recommend that your new generator have a scrub_ function that (recursively) appends the code for the next block onto the current code.
Julian
unread,
Sep 29, 2021, 12:16:01 PM9/29/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Blockly
Hello Neil,
Thx for your time and the solution / example . Just like you suggested I didn't have a _scrub function after finding this out it worked. However I forgot to to share that I already solved it here.