Why can't I get the information on the back block of my pdtmf1

21 views
Skip to first unread message

xuesong

unread,
Nov 22, 2023, 4:31:55 AM11/22/23
to Blockly
this is my code微信图片_20231121100507.png微信图片_20231121100541.png
this is my blockly
微信图片_20231121100614.png
this is my console 
微信图片_20231121100631.png
I am a blockly beginner, but also hope that you give a little help
Thanks!!!

Christopher Allen

unread,
Nov 23, 2023, 4:01:52 PM11/23/23
to blo...@googlegroups.com
Hello,

I'm not 100% sure I understand your code; I can't read the alphabet the blocks in your screenshot are labelled with, so I have to match them up against the definitions by shape and hex colour (which do not match exactly any of the colours actually shown in the picture), so I might be confused, but I notice two issues;
  • Both the 'menu' and 'submenu' blocks each have both a field and an input named 'NAME'.  There's nothing strictly _wrong_ with this—inputs and fields have different namespaces—but it is definitely confusing.
  • The generator function for the 'Pdtmf1' block calls javascriptGenerator.statementToCode(block, 'STATEMENTS'), but this block does not have any input named 'STATEMENTS', only one called 'NAME'.
I think both issues can be fixed by changing this.appendStatementInput('NAME') to this.appendStatementInput('STATEMENTS') in the block definitions for 'menu' and 'submenu'.

By the way: I think it is unhelpful that CodeGenerator.prototype.statementToCode returns an empty string when given a non-existent input name; I think it would have been easier for you if it had thrown an error, so I've filed a feature request suggesting that we change this.


Best wishes,

Christopher
Reply all
Reply to author
Forward
0 new messages