Compiling Programs

You can explicitly compile a program by using a COMPILE statement. If you do not explicitly compile a program, then it is compiled when you run the program for the first time.

When a program is compiled, it translates the program statements into efficient processed code that executes much more rapidly than the original text of the program. When errors are encountered in the program, then the compilation is not completed, and the program is considered to be uncompiled.

After you compile a program, the compiled code is used each time you run the program in the current session. When you update and commit your analytic workspace after compiling a program, the compiled code is saved in your analytic workspace and used to run the program in future sessions. Therefore, you should be sure to update and commit after compiling a program. This is particularly critical when the program is part of an application that is run by many users. Unless the compiled version of the program is saved in the analytic workspace, the program is recompiled individually in each user session.

Example 9-68, "Compiling a Program" illustrates using COMPILE to compile a program

Finding Out If a Program Has Been Compiled

You can use the ISCOMPILED choice of the OBJ function to determine whether a specific program in your analytic workspace has been compiled since the last time it was modified. The function returns a Boolean value.


Programming Methods That Prevent Compilation

Program lines that include ampersand substitution are not compiled. Any syntax errors are not caught until the program is run. A program whose other lines compiled correctly is considered to be a compiled program.

When your program defines an object and then uses the object in the program, the program cannot be compiled. COMPILE treats the reference to the object as a misspelling because the object does not yet exist in the analytic workspace.