Code re-use PLEASE


In mBot 3 we had a workaround to be able to re-use code by loading it into a sprite and saving the sprite, then loading the sprite in the new program.
In mblock 5 there seems no such workaround.

This is important to teach modularity in programming. The value of MyBlocks is much reduced to the students if they have no way to copy from one program to another.

The best workaround I found so far is to add all my code block in a starter file, then once the new program has been written, delete the unused blocks to save Arduino memory. Its a kluge.

I suggest the support for multiple robots be extended to support file save and open per robot. Then the code can be copied and pasted from a previous program to the program under development.


Good comment.

mBlock 5 is in Beta stage now, and the final version will certainly include features similar to Sprite import/export.


I fully agree. I would like to be able to have some standard personal function I could import and re-use on multiple programs!


Was this implemented somehow ?
I would like to have an option to reuse some blocks.

For example I have a code to monitor Device’s (Codey Rocky) battery level.
I would like to reuse that code in other projects.


I don’t believe this is implemented yet.

I did also request that they created a clip board that code and be copied to and the pasted from in another program.


Hello everyone,

I like the idea of COPY / PASTE. It exists in mBlock but only between the same project. You take your section of code and drag it onto sprite / device. A PASTE / PASTE between project would be very useful.

Another possibility that would be useful. Export code to a file other than (.sprite3) I would like a file with a single block of code, maybe in a (.script). I would add it to this menu as the image functionality.
By the way, I just discovered this feature which is great.

Finally, the only possibility is the export / import of sprites with their code.


What are these features ??? Your answer is almost a year old.


I would like to see the ability to have multiple programs open at once just in different tabs and the ability to copy and paste between tabs/programs. When you copy code it is placed on a clipboard that can be pasted later in another program. This would be much like an IDE that a programmer would use for a textual language


@Crackel @OutoftheBOTS
If you want to re-use the code, you just need to save the current project to another project for example [copy], then you can open the project [copy] and edit it.
Also you can save the project to your computer.
Even the device and sprite can be saved separated by export as Crackel showed.
About the request to open multiple programs at once and the ability to copy and paste.
I’m sorry the blocks can’t copyed to another page at present and it is not in the support plan.
You can open multiple programs using mBlock5 webpage.
To re-use the code, you can export and import or save to other projects.


Indeed, but the export copies the whole code and not a section. Here is the best solution and you have implement the concept with the image of a section of code. It remains to implement the concept with a section of code.

Add : Export this script section to .script5


Yes, but you can copy the whole code and delete the parts that you don’t need.
By the way, some users need the function to export as image.


By the way, some users need the function to export as an image.

In fact, this feature is excellent. I had to use external document capture software. This is the reason why I say that you could think of the same functionality but for the code.

Otherwise, you mBlock is excellent … We criticize because we love it.


Yes, thanks for your trust to Makeblock.
We are keeping improving the software.