Tutorial 19 - Keep your code separate

Written By Akki On Friday, November 16, 2007

Tutorial 19 - Keep your code separate

Keep your code separate by Richard Gamester

Following on from All About Forms, I would like to tell you about keeping your code safe.
No, not backup's - that should be normal practice, but the best way to control your ever expanding code, but first we need to understand this bit of the PPL window:

Project.gif


This is your friend the Project Manager, this is where you can list all the parts of your project. As before, I will be using my Test project, in the folder Test. The first thing you need to do is add your form. Click the green plus icon and open the Test.frm file. Do not be tempted to add the Test.ppl file of the same name, it will only confuse you later. This file is the one auto-generated by PPL.

The Project Manager is the quickest way to open your form (frm) or code file (ppl) if you close them in the main window. To be safe, you should place all your main-line code in additional .ppl files.
Doing this is quite simple:

Click File > New

You now have a blank form to put your code in! But I suggest you do the housekeeping first and..

Click File > Save

Save your new file and call it something meaningful like Test2.ppl, save it in the project folder with the Test.frm file, then add it to the project list in the same way as you loaded the form.

The next thing to do is tell PPL about your file.

This is quite simple, just add a statement like this to the Form > Initalization Section Code area..

#include "Test2.ppl"

You can then cut and paste your code as procedures or functions in the new file

Here is one last thought. If your routine Test2.ppl relies on several sub routines, these can be put in Test3.ppl.

But this time put the #include for it at the top of the Test2.ppl file.

This has the advantage that your sub-routines are defined before the calling code, so you will not need to use forward statements.

Share and Enjoy:
  • del.icio.us
  • StumbleUpon
  • Digg
  • Sphinn
  • Facebook
  • Mixx
  • Reddit
  • Technorati
  • IndianPad
  • YahooMyWeb

No Comments