CHAPTER 11: Compiling, Linking, Running, and Executing


Once you finish the coding for an application, you must prepare it for use. Then it can be executed.



11.1 Compiling and Linking Applications

There are two steps involved in compiling an Empress 4GL application. The first step is the compile phase, and the second step is the link phase.


11.1.1 Compiling

When you compile an application, Empress 4GL starts creating the internal p-code which is used to run the application. Then, the results of this phase are stored in the sys_4gl_compile table in the database. To perform this compilation, you can use one of several ways.

You can compile the application from the Empress 4GL development application. In the Application window, function keys and a pop-up Tables Menu are available. Once you select the function to compile the application, a small window will indicate that the compile is taking place.

Compiling can also be done from the shell by using the -c option for the emp4gl command. Select the -c option and the names of the applications you would like to compile, and the compile will take place.


11.1.2 Linking

Once all the compiles have been successfully accomplished, you must link the modules together. Apply the link function to one application. This application should have references to all the other applications you would like to link. When the link has been performed, the results of the link phase, more p-code, is inserted into the sys_4gl_link table in the database. This is the executable for the application.

To link applications, use the menus within the application or the -l option for emp4gl.


11.1.3 Errors

If there are errors after compiling or linking the application, Empress 4GL lets you display a list of errors. This feature allows you to find and correct all compile and link errors, as opposed to runtime errors.

Errors can be displayed within the development application in one of two ways. If the application window is active, use the Errors function to display a window with a list of the errors from the most recent compile or link. However, you must remove this window in order to edit the application and change the code.

In the Application window for the application, the Errors function allows the first error Empress 4GL encounters to appear in a window at the bottom of the screen. This window remains at the bottom of the screen until you exit the application, press the Errors function again, or receive a successful compile or link. Therefore you can see the error while you find the correct script and change it.

The most common errors at compile time are syntax errors and omissions on definitions (for example, forgetting the coordinates for a window). Common link errors include references to forms that are not in any of the applications, and duplicate items.



11.2 Running an Application

Once you have compiled and linked the application, you can run it. Once again, there are several ways in which you can run the application.

First, you can use the menus in the development application. If compile and link are options, run is usually an option as well.

However, the most common method of running an application when it is in production is from another application, like a menu. To do this, use the CALL APPLICATION command in the Empress 4GL script language.

You must still have a method to start up the menu application from the shell. To do this, specify the application name as an argument for the emp4gl command. If you name an application, Empress 4GL will go into runtime mode and execute the application.

Runtime mode differs from Empress 4GL's full mode in that the development application and debugger are not included in the runtime mode. This helps the production versions of applications to load more quickly, run more quickly, and use less memory.

Another option for the emp4gl command is the -p option. The -p option requires an application name as an argument. The application is then pre-retrieved so that it will not take as long to load when it is called. This is very useful for a set of applications that are grouped together with a menu application as the front end. You can call the menu application first with all the other pre-retrieved applications so that it is faster to switch from one application to another.



11.3 Building an Empress Executable

You can create an executable module with a set of Empress 4GL applications and a set of terminal definitions. The emp4bldx command does this. It prompts for the names of the terminal definitions applications, and so on and creates source files for a C program. It then compiles the C program to come up with an executable.

This provides an application which is faster to load and run than using the p-code version.

To call an application that has been built into an executable, run the executable as a normal program. It will have an option to pass a database name (-d option) and an application name (-a option).

The database that is passed will become the default database for the applications. If you do not specify a database, there will be no default unless the application sets one.

The application parameter is the name of the application that is to be started (since there can be many in one executable). If it is left "off", the first parameter in the emp4bldx command will be executed.