Creating an interface with ConsoleUI

Use the following steps to create an interface with ConsoleUI:

  1. Create an EGL source file
  2. Write a program that includes the language elements described in ConsoleUI parts and related variables
  3. Generate Java™ code from the EGL source file
  4. Run the generated Java file as an application

Each of these tasks is detailed below.

Creating an EGL source file
  1. In the workbench, from the EGL Perspective, select File>New>EGL Source File. Or, from any perspective, select File>New>Other>EGL Source File..
  2. In the wizard screen, enter the following information:
    • Source Folder: the directory location that will contain the EGL source file.
    • Package: the package location that will contain the EGL source file. This field is optional.
    • EGL Source File Name: the filename of the Console UI source file, such as myConsoleUI.
  3. Select Finish to create the file. An extension (.egl) is automatically appended to the end of the file name. The EGL source file appears in the Project Explorer view and automatically opens in the default EGL editor.

Writing the ConsoleUI program

To populate the source file and create the interface, you will need ConsoleUI variables and functions. to use the ConsoleUI language elements, which are introduced in the overview help topic, and defined thoroughly in the individual ConsoleUI Library, OpenUI Statement, Record types, and Enumerations help topics.

A ConsoleUI application must include, at a minimum, the following elements:
  1. PROGRAM...END
  2. Function main ()
  3. OpenUI Statement
Note: Although the OpenUI statement is fundamental to the ConsoleUI, you can write a successful ConsoleUI program without an OpenUI statement.

Generating Java code from EGL source

To generate a Java file:
  1. In the EGL Editor, right-click on the ConsoleUI file. A context menu displays.
  2. Select Generate.
Note: A ConsoleUI .egl source file cannot be generated to COBOL.

Run the generated Java file as an application

To run the generated Java file:
  1. From the Project Explorer, right-click on the generated Java (.java) file. A context menu displays.
  2. Select Run>Run As>Java Application.
  3. Or, with the Java file open in the editor, select Run>Run As>Java Application from the main menu.
  4. Your ConsoleUI will display to a window.

A ConsoleUI application can display in either a curses-based terminal session or a Swing-based graphical window. UNIX® users have a more flexible display choice, which is described in the ConsoleUI screen options for UNIX help topic.

Note: IBM®

Related concepts
Console user interface

Related reference
EGL library ConsoleLib
ConsoleUI parts and related variables
ConsoleUI screen options for UNIX
openUI

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.