So you have your main program:
:mainprgm()
:Prgm
(program code)
:EndPrgm
When you want to define a subprogram (usually near the beginning of your program) you add something like this:
:Define subprgm(arg1,arg2)=Prgm
(subprogram code)
:EndPrgm
Functions are defined using Func..EndFunc in the same way.
A key point is that in such a setup, 'subprgm' is a variable like any other. If you don't get rid of it, it will be left as an external program after you run the main program. As with other variables, you can define it as Local, DelVar it, or make its name one letter long and NewProb it (see Setup and Cleanup for more details).