Script Copy / Paste Fails with message "Undefined function: primName"

Issue #103 resolved
Turgut Guneysu created an issue

Hi John,

All of a sudden, pasting copied script blocks via Clipboard does not work. At least in one specific case with one of my programs.

Dos window error is: Undefined function: primName

Debug display blocks:

I cannot attach a failing program, since I am trying to insert the copied blocks into a new program. However, attached is the XML of the copied blocks from the Clipboard that I pasted into a DOC, if it will help.

ALSO:

I used to be able to copy individual blocks, specially the custom ones. I can no longer get the COPY BLOCK menu option on right click.

Comments (10)

  1. John Maloney repo owner

    I haven’t completely tracked this down, but I do have a work-around. Paste the clipboard into a text editor and delete any empty scripts that look like this:

    script 50 371 {
    }

    Then copy the contents of the text editor and paste it into MicroBlocks.

    I can make it tolerate the empty scripts but I’m wondering where they are coming from. It’s possible that they are block definitions. Unfortunately, the current copy-paste doesn’t handle block definitions. The workaround is to detach the body of the block definition, copy-paste the body, create a new block definition hat block for it in the new project, and attach the pasted body to it. Awkward, but often better than having to recreate the script from scratch.

  2. Turgut Guneysu reporter

    Just wanted to revisit this one to verify its status:

    In another issue, you said copy/paste worked. I did not quite understand if this is for all instances of copying or just for the Browser in between tabs version.

    As of my current testing (Sept.10,2020), I cannot copy from stand-alone version into Browser for the reason that CUSTOM blocks do not copy.

    Thanks to clarify.

  3. John Maloney repo owner

    There are different issues, although both involve copy-paste. The other issue is about the copy-paste mechanism working for anything – including simple text – in the browser. That used to to not work due to browser security limitations. However, Google recently added a new clipboard API to their Chrome browser (which also applies to the Chromium-based Edge browser) that made it possible to implement copy paste in Chrome/Edge browsers. But that’s fine; those are the only browsers that all MicroBlocks to talk to boards and, hence, the only ones we support.

    This issue involves copying and pasting empty scripts like:

    script 50 2326 {
    }

    I can’t figure out what’s making that empty script appear in the textual form of he code. If this happens again, it would be great if you could save a copy of the project from which you were trying to copy all the scripts so I could figure out how to reproduce it.

    Have you run into this issue again recently?

    I mentioned one work-around above. A different work-around is to copy and paste one script at at a time. Note that you currently need to be in in “advanced blocks” mode in order to get the “copy script to clipboard” menu command for an script. (But I’ll change that. It doesn’t make sense that “copy all scripts to clipboard” doesn’t require “advanced blocks” mode but copying an individual script does.)

  4. Turgut Guneysu reporter

    >>> Changed issue to Critical ! Edit if not appropriate.

    I was still encountering this error today !

    So first I tried the ADVANCED mode tip. And I noticed that in either advanced or not advanced, the blocks are correctly copied to the clipboard.

    But either way, it was NOT pasting.

    So I started examining the blocks themselves.

    I noticed that certain blocks, listed below, cause this error. If they appear in any sequence of blocks, copy /pasting that sequence will NOT work.

    Copy / Paste test can be done in the IDE by simply clicking on a block and selecting copy to clipboard, followed by paste blocks from clipboard into the IDE.

    I have verified this by copying sequences without these and then adding them, which made them fail at paste.

    Also, copy sequences with them to clipboard, deleting the offending blocks, copying them again and pasting them into microBlocks successfully.

    I have examined all the std blocks plus the LED Display and Radio libraries.

    I have NOT examined any other libraries. It is tedious, but I was hoping from theses below, you can extract a pattern to fix it.

    If not, I will go through the rest of the libraries as well. But I will wait for your results first.

    BLOCKS causing copy / paste errors even in advanced mode:

  5. John Maloney repo owner

    Thanks for reporting this! I introduced a bug when I added the code to add global variables referenced by the copied script. Thanks to your list of examples, I do see the patterns and there is an easy fix.

  6. Log in to comment