repeating sketches

Hi all,

I need to parse serial data in two directions as there will be two way communication between an esp8266 and Arduino mega.

Is there a way to write a sketch that can be called from multiple sketches when compiling?

Is there a way to write a sketch that can be called from multiple sketches when compiling?

Sorry no idea what that means can you explain what you want to happen.

If you want to share code between multiple sketches, the way to do it is with a library. You can find a tutorial to writing your own libraries here:
https://www.arduino.cc/en/Hacking/LibraryTutorial

sorry, I realise that was not very clear.

I did mean writing a library which I will now look into, thank you