Modules
Let's take it a stage even further. Right now, our pegObject routine is still "hard-wired" into the program. We want to be able to make this routine available to all your other programs without having to cut and paste all over the place. The only answer is to pull it out of your program and save it separately. Then you can call it from any program. Let's see how to do it:
The invocation to the routine remains unchanged but the file is stored externally to the program and we can invoke it from any other program.
The process outlined above seems a little complicated but, remember, that's only because we had
the code already written in our main program. If we were writing a new application that needed this module, all we have to do to embed it into the code is to select the Project menu and select "Add existing file ..." and navigate to the location of you module file. As soon as you have loaded the file, its routines will be visible in the properties window of that module. Easy.