Try OpenEdge Now
skip to main content
ABL Essentials
Using Basic ABL Constructs : Saving and compiling your test procedure
 

Saving and compiling your test procedure

You've written your first ABL procedure. As you make changes to it, you should re-save it by selecting File > Save from the Procedure Editor menu or by just pressing F6.
This section examines what happens when you press the F2 key or select Compile > Run from the menu to run your procedure:
1. When you tell the AVM to run your procedure in this way, the Procedure Editor creates a temporary file from the ABL code currently in the editor window and then passes this file to the ABL compiler.
2. The compiler performs a syntax analysis of the procedure and stops with one or more error messages if it detects any errors in your ABL statements.
3. If your procedure is error-free, the compiler then translates or compiles your procedure into an intermediate form that is then interpreted by the AVM to execute the statements in the procedure. This intermediate form is called r-code, for run-time code. It is not a binary executable but rather a largely platform-independent set of instructions (independent except for the user interface specifics, that is).
4. The AVM reads and executes the r-code.
This ability to compile and run what is in the editor on the fly makes it easy for you to build and test procedures in an iterative way, making a change as you have done and then simply running the procedure to see the effects. Naturally, you want to save the r-code permanently when you have finished a procedure so that the AVM can skip the compilation step when you run the procedure and simply execute the r-code directly. Generally it is just the compiled r-code that you deploy as your finished application.
To save the source procedure itself, use the standard File > Save As menu option in the Procedure Editor, which saves the contents of the editor out to disk and gives it a filename with a .p extension.
To compile a procedure that you have saved, you need to use the COMPILE statement in ABL. There's a COMPILE statement rather than just having a single key to press because the COMPILE statement in fact has a lot of options to it, including where the compiled code is saved, whether a cross-reference file is generated to help you debug your application, and so forth. For now, it is sufficient to know just the simple form of the statement you use to save your compiled procedure.
To compile your test procedure:
1. From the Procedure Editor, select File > New Procedure Window.
Another editor window appears that has all the same capabilities as the one with which you started out, except that not all the menu options are available from it. You can be working with any number of procedure windows at one time, and save them independently as separate named procedures. Or you can bring up a window just to execute a statement, as you are doing now.
2. In the new editor window, enter the following statement:
COMPILE h-CustSample.p SAVE.
3. Press F2 or select Compile > Run. The procedure window disappears and almost immediately returns.
The compilation of h-CustSample.p is complete. If the compiler had detected any syntax errors in the procedure, you would have seen them and the procedure would not have compiled.
If you check your working directory you can see the compiled procedure. It has the .r extension and is commonly referred to as a .r file.
One option for the COMPILE statement is worth mentioning at this time. You can specify a different directory for your .r files. This is a good idea, especially when you get to the point where you are ready to start testing completed parts of your application. Use this syntax:
COMPILE source-procedure SAVE INTO directory.
If you need to recompile a large number of procedures at once, you can use a special tool to do that for you. This is available through the Tools > Application Compiler option on the Procedure Editor.