If the same code need to be repeated multiple times, or if the code needs to be distinguished according to its role,  you can make the code as a function, and can all the function whenever necessary.  This is similar to the concept of a function in C language.  The only difference is that there are no return values and input parameters. When used properly, you can easily figure out  the flows of the program,  and can avoid to write the same command lines again and again.  Functions are executed by calling them. After a called function ends, execution will be returned to the point of the calling and started from the next command line.