Code re-use PLEASE


#1

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.


#2

Good comment.

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


#3

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


#4

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.


#5

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.


#6

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.
image
By the way, I just discovered this feature which is great.

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


#7

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


#8

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


#9

@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.
image
image
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. https://www.mblock.cc/
To re-use the code, you can export and import or save to other projects.
Thanks.


#10

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.
go

Add : Export this script section to .script5


#11

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.


#12

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.


#13

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