Release 10.1A: OpenEdge Development:
Progress 4GL Handbook

> ## Saving and compiling your test procedure

> You’ve written your first Progress 4GL procedure. As you make changes to it, you should resave 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 Progress to run your procedure in this way, the Procedure Editor creates a temporary file from the 4GL code currently in the editor window and then passes this file to the Progress 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 4GL 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 Progress run-time interpreter 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 Progress run-time interpreter reads and executes the r-code.

> This ability to compile and run what’s 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 Progress 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 the 4GL. 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.

> Now you’ve compiled your first procedure! In the next chapter, you learn how to run one procedure from another.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095