Like many types of applications with user interfaces, EGL Console UI applications separate the interface from the logic used to create that interface. An ordinary EGL program provides the logic for the application, while several different types of parts can represent the interface itself.
A ConsoleForm part is a record of fields to be shown on the user interface. The fields in this type of record do not store data or have a data type such as INT like the fields in other types of records. Instead, the fields in a ConsoleForm define the location and label of the fields that are shown on the screen. As a group, these fields are sometimes referred to as a form. The Console UI program links the fields on the screen with other EGL variables.
Record CustomerConsoleRecord type consoleForm
{formSize = [10,40],name = "Customer Record"}
* consoleField {position = [1,4],
value = "Welcome to my console."};
ID consoleField {fieldLen = 5, position = [3,4],
name="customer_id"};
Fname consoleField {fieldLen = 20, position = [4,4],
name="first_name"};
Lname consoleField {fieldLen = 20, position = [5,4],
name="last_name"};
PhoneNum consoleField {fieldLen = 20, position = [6,4],
name="phone"};
end
Of the five fields in this form, one is a constant
string of
text; it cannot change at run time. This field is named with an asterisk
(*)
and serves as header or explanatory text, in this case "Welcome to
my console."
The other fields are variable; a Console UI program can use them to
display
data or accept input.new Menu {labelText = "Choose an option: ",
menuItems = [
new MenuItem{name = "One", labelText = "Option One"},
new MenuItem{name = "Two", labelText = "Option Two"},
new MenuItem{name = "Three", labelText = "Option Three"}
]}
See Creating a Console User Interface for an example of how to respond when the user selects one of the options.
An ArrayDictionary is a type of EGL part that is often used to represent data in Console UI. Unlike an array of records, in which you define one record part that represents a row and then create an array of those rows, in an ArrayDictionary, you define arrays of consoleFields that represent the columns. Defining data by the columns can be useful in Console UI because ArrayDictionaries scroll automatically in the limited space on a Console UI window.
A detailed example of an ArrayDictionary in Console UI is available at Using an array dictionary in Console UI.
A detailed example of an ArrayDictionary in Console UI is available at "Using an array dictionary in Console UI" in the EGL Language Reference.
program CreateAConsole type BasicProgram
function main()
// Step 1: Create a variable for the form.
myConsoleUIRecord CustomerConsoleRecord;
// Step 2: Create a window, but don't open it yet.
myWindow window {name="My Window", position=[1,1]};
// Step 3: Create variables for the form fields.
customer_id int;
first_name, last_name, phone char(30);
// Step 4: Open the window and open the form inside the window.
consoleLib.openWindowWithForm(myWindow,myConsoleUIRecord);
// Step 5: Link the variables to the fields in the form.
openUI myConsoleUIRecord
bind customer_id, first_name, last_name, phone
end
end
end
For more information on using Console UI programs, see Creating a Console User Interface.
With EGL, you can run your Console UI projects in a variety of modes. If you want to run your Console UI application in rich client application (RCP) mode, you need to convert your project to an EGL plug-in project.
For more information about the modes you can run your Console UI application in, see Console UI modes. For more information on EGL plug-in projects, see Creating an EGL plug-in project.