In Fortran, I can use
include "file" to insert a piece of code. Is there a similar method in Mathematica?
The answer is very simple:
Put your external code snippet into a file
toInclude.m, for example with the content
Now in the "parent" notebook (assuming it's in the same directory as the code snippet), execute the command