CHAPTER 1: Application Components


There are four important components in an Empress 4GL application. In order to be able to build an application, you should learn about the components. These components are:

The first three components are inter-related. Fields are part of a form and windows are the only way that you or the application can access a form.

Note The function keys used in examples in this manual may not correspond to the keys on your terminal.



1.1 Forms

A form defines the data area for an Empress 4GL application. You use forms to define the information that Empress 4GL displays and to determine the place where you can enter information for the application to process.

Forms consist of background and foreground sections. The background contains the text, lines, boxes, and video regions, while the foreground contains the fields that you fill in with information.

Empress 4GL can only use forms in an application if they are visible through windows. When you define a window, you include its form in the definition. Any other references to that form will be made through the window.

In your application, define each window with only one form; however, several windows can look at a single form. This brings up the concept of form instances. With form instances, you can have more than one window looking at a single form, but this window accesses distinct copies of the form or the exact same copy of the form.

Imagine that a form in Empress 4GL is like AAA Software's job application form. When people apply for a job at AAA Software, they fill out job application forms which request certain information. When the applicant completes the form, AAA Software's personnel department takes copies of the form and puts each copy in a separate type of file. However, before the forms can be put into files, they must be given unique numbers to distinguish them from one another.

In Empress 4GL, each physical copy of the form is called an instance. The form itself is not a physical thing, it is an idea or definition. The form cannot be used unless there is a form instance to work with. In our analogy, if two people fill out applications at the same time, the applications should be given two different forms or instances so that they do not need to use the same form.

A form has no size limitations. It can be larger than the window that Empress 4GL uses to display the form. In fact, it can be larger than the screen on the terminal. If the form is larger than the window or the screen, Empress 4GL lets you scroll within the window so that you can see different parts.



1.2 Windows

A window displays the form on the screen. The window is a rectangular area that you can place anywhere on the screen by defining its upper left and lower right corner coordinates. You can also place a box around it and, by using an application, you can manipulate it in several different ways.

Many windows can appear on the screen at any time. However, only one can be the current window. The current window is the one that you interface with. It does not necessarily have to be completely visible (i.e. there can be another window overlapping it). In fact, it can be completely invisible. To set the current window, you would use a command in the application.

With each window, you can define sets of key definitions that will become active when that window is current. This makes it easy to have the function keys behave appropriately within different windows.

You can make windows visible or invisible as well as resize them and move them around on the screen. The only limitations on a window is that the entire window must be on the terminal screen, although parts of the window can be hidden behind other windows.



1.3 Fields

A field is defined as a space on the foreground of the form. It has a set size although you can enter or display data that is larger than the field. In such a case, you can scroll around the field to see all the data.

Fields do not have to be a single block on the form. They can consist of several lines that may or may not be joined. You may also have arrays of fields known as multi-fields. With multi-fields, the application can easily deal with more than one record at a time. In order to use a field in an application, you must refer to the form instance.

In order to refer to a field properly, you attach each form to a window name to let Empress 4GL know what instance of the field is associated with what window.

Empress 4GL lets you define the available fields for each window. You can also define certain characteristics (such as the data type and the mode) for each field that belongs to a window. Keep in mind that the same field can belong to different windows and have different types, modes, and so on in each window.

Within each window, you may define one field as the current field. When the window is current, the current field is the one in which the cursor appears. It is the field with which you can interact.

When dealing with fields in Empress 4GL, please remember that the fields do not relate to table attributes in any way. You can design the application so that the transfer of information from fields to attributes is easy, but the fields and the attributes are not related in any way within Empress 4GL.



1.4 Scripts

The last major component of an Empress 4GL application is the script. This is a procedural module which tells Empress 4GL what to do at various times. There are several types of scripts: scripts that correspond to certain events and subscripts, which are procedures that can be called from any other script. All of these scripts use the same procedural language which is very high level but very easy to use.

Most script commands take the form of function calls which can take parameters and return values. There are also commands and functions that allow you to deal with common situations much easier, such as multi-field windows, direct transfer of data to the table buffers, and field data validation based on attribute validation guidelines.

In addition, you can use a set of commands to help you handle errors, or pass control of the error handling to Empress 4GL