Duplicate output is generating for procedure block.

105 views
Skip to first unread message

Naresh Chaudhari

unread,
May 14, 2021, 7:28:06 AM5/14/21
to Blockly
Hi @All, I have created a block for a procedure using "procedures_defreturn" and changed the IDKey to "custom_procedures_defreturn", and used the same code from the procedure file.

My problem is... 1.) When I join/attached with the next block (two blocks) the output of the next block is generating twice(Duplication).

If there is only one block and it is not connected the code is generating only once.
If two blocks are connected then the second block output is generating twice.
if there the three-block attached then the output is generating x2. I have attached small videos Please look at once... Filename: ( screencast-nimbus-capture-2021.05.14-16_08_36.webm )

I have changed some code from the "custom_procedures_defreturn" in the generated stub block...

// Blockly.Python.definitions_["%" + d] = b;
    return b

// Blockly.Python.definitions_["%" + d] = b; I have commented this line because I want to generate function code inside class. 

Capture.PNG
In the screenshot you can see... I have used two functions called unnamed and unnamed2. But in the generated code it is showing duplicate for unnamed2. how to fixed it? 

2.)  Also if I right-click on the custom_procedures_defreturn block and create "function call" using the "Create 'Function' name then also one more block is creating automatically." which is captured in the small videos at: 0.35 secs 

Please help me out to fix the issue... 

Your help will be highly appreciated. 

screencast-nimbus-capture-2021.05.14-16_08_36.webm

Beka Westberg

unread,
May 14, 2021, 5:26:42 PM5/14/21
to blo...@googlegroups.com
Hello,

In the current version of Blockly, getDefinition doesn't work properly for procedure blocks that are children of other blocks :/ I imagine this is what is causing problems with your code generation. There is a pull request that fixes this issue with getDefinition, but the code from that won't be available until the next release. You could try monkey patching your version with the changes in that PR to see if that fixes your problem, but it may be better to wait for the release.

Sorry I can't be more help :/
--Beka

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/3a17fdeb-76fa-4896-b5e8-1e1b08b33dcfn%40googlegroups.com.

Naresh Chaudhari

unread,
May 17, 2021, 1:32:33 AM5/17/21
to Blockly
Hi Beka,

You could try monkey patching your version with the changes in that PR to see if that fixes your problem ==> Who it can be done?

==> Do I know when do we have the next release with bug fixes?(Next release date)

Beka Westberg

unread,
May 17, 2021, 6:51:35 PM5/17/21
to blo...@googlegroups.com
Hello,

You should be able to monkey-patch it in by adding code like the below somewhere before you inject your workspace. But you might want to wait on that. As you can see here, there's a discussion ongoing about whether this change actually does more good or more harm hehe.

```
Blockly.Procedures.getDefinition = function(name, workspace) {
  var blocks = workspace.getAllBlocks(false);
  for (var i = 0; i < blocks.length; i++) {
    if (blocks[i].getProcedureDef) {
      var procedureBlock = blocks[i];
      var tuple = procedureBlock.getProcedureDef();
      if (tuple && Blockly.Names.equals(tuple[0], name)) {
        return blocks[i];
      }
    }
  }
  return null;
};
```

Sadly I do not know when the next release will be :/ But I think it should be around the end of June? The core library is released about every three months, and the last release was March 25.

Best wishes,
--Beka

Abby Schmiedt

unread,
May 17, 2021, 9:28:42 PM5/17/21
to Blockly

Hello!

The next release date will most likely be on July 1st. 

Cheers, 
Abby
Reply all
Reply to author
Forward
0 new messages