Insert code from one program into an other program


#1

Hi
I have made a program and I want to use this code in an onther programm I have already written. I am sure there will be a way, but can anyone tell me how that works? Thank you. :keyboard::computer_mouse:


#2

Can you describe what you want in more detail?


#3

Yes I can !
I have wirtten a programm for using the remote control with several function which is now a few pages long. And I want to have a function that I did not know how to program it. So I wrote a new program and testet it. It took me some time to get it like I liked it. So now this function is good I want to put it in the program for the remote control. I can put it in step by step, but the risk of making mistakes is high and it took me some time. Unfortunatly you can not do a copy paste thing in grafic mode. But you can probably to some copy paste with the arduino code shown in Arduino mode. But I do not know how.:question:
Thanks


#4

I made a screenshot of my program and copied it to the other program. I did not find an other possibility so far… Copy and paste would be fine here !!


#5

You did the functions with the blocks and want to use them in other projects in the program mBlock? I would also like to this opportunity was. But at the moment the only way I know is to make your extension, and in this extension make your own blocks, to perform some your functions. It certainly is difficult and requires programming skills…


#6

Yes, I wanted to copy blocks in other programms. I tried arduino mode, but I failed with this.
But what about “make your own extension”. I have no idea what that is.


#7

You make your own extension by instruction: http://www.mblock.cc/docs/create-extensions-for-mblock/
In extension you define block and write your code for it. Then you use block in project and this block insert your code into program.

You make your block and insert code of your function, what you made before. Then you use it in other project and can share your blocks as extension.!


#8

Open the file that has the code that you want to copy.

Create a new sprite.

Drag the code that you want to copy and drop it onto the new sprite icon.

Click the new sprite to check that all the code you want has been copied.

Save the sprite as a new sprite file (not a program file).

Save the program file.

Open the file that you want to copy the code to.

Insert a new sprite and select the sprite file that has the code you copied.

Click the sprite. Drag and drop the code from the sprite to the main program sprite.


#9

Thank you for the last 2 replys. I do understand both and already tried a little bit. But a real copy and paste is still missing…


#10

Here you have a video to do it with sprites as @goatsongs has explained.