Use of new in ConsoleUI

When you create an EGL program that uses consoleUI, every variable of type Menu, MenuItem, Prompt, and Window is a reference variable, which contains a memory address that refers to a value stored outside the variable.

You can declare a reference variable as you declare any other, as in this example:
  myPrompt Prompt { message = "Type your ID: "}; 
Alternatively, you can declare a reference variable and initialize it with the reserved word new, as in this example:
  myPrompt Prompt = new Prompt { message = "Type your ID: "}; 

When you are declaring variables, the difference between the two formats has little practical effect; but when you code the openUI statement, the word new provides a coding convenience, as shown in openUI.

The general syntax for new is as follows:
  new partName
partName
One of the following words, which refers to a particular kind of part:
  • Menu
  • MenuItem
  • Prompt
  • Window

For details on other implications of reference variables, see Reference compatibility in EGL.

Related concepts
Console user interface

Related reference
ConsoleUI parts and related variables
openUI
Reference compatibility in EGL

Related tasks
Creating an interface with ConsoleUI

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