The OpenUI statement allows the user to interact with a program whose interface is based on consoleUI. The statement defines user and program events and specifies how to respond to each.
The syntax of the OpenUI statement is as follows:
allowAppend = yes, allowDelete = no
Indicates how to bind a series of variables to a series of ConsoleFields; specifically, whether to match each variable name with a ConsoleField name. The variable name is listed in BindClause, and the ConsoleField name is the value in the ConsoleField name field.
Whether consoleFields are listed explicitly in the openUI statement or are listed in a dictionary declaration, their order defines the order of consoleFields for the purpose of binding by position. (Their order also defines the tab order for user input, as noted in ConsoleUI parts and related variables.)
If a consoleField is listed or is in a dictionary declaration when no matching variable is in the binding list, the user's input to the consoleField is ignored. Similarly, a binding variable that does not match any field is ignored.
At least one consoleField and variable must be bound together at run time; otherwise, an error occurs.
This help text is for the openUI command. In some cases, the text associated with the key is more context specific. For instance, each option in a menu can have its own help message.
The resource bundle is identified by the system variable ConsoleLib.messageResource, as described in messageResource.
Specifies whether the purpose of the openUI statement is to create selection criteria for use in an SQL statement such as SELECT.
The openUI statement must be bound to a single variable of a character type. That variable does not provide initial values for the ConsoleFields, but does receive the user's input, which is formatted for use in an SQL WHERE clause.
If the value of setInitial is no, the values of the bound variables are fetched and displayed initially.
For details on binding, see the section on OnEventBlock (later), as well as ConsoleUI parts and related variables.
OnEvent(eventKind: eventQualifiers)
The EGL statements that respond to a given event are between the OnEvent header and the next OnEvent header (if any), as shown in a later example. However, you cannot include a reference variable in the OnEvent block unless that variable was declared as a program global.
No event block is available for a window.
openUI {bindingByName=yes} activeForm bind firstName, lastName, ID OnEvent(AFTER_FIELD:"ID") if (employeeID == 700) firstName = "Angela"; lastName = "Smith"; end end
You can end an openUI statement by issuing an exit statement of the form exit openUI.
ON_KEY:("a", "ESC")
This event is available in an ArrayDictionary, a ConsoleField, a Menu, or a Prompt.
BEFORE_FIELD:("field01", "field02")
AFTER_FIELD:("field01", "field02")
The user can edit the row before committing changes to a database, as typically happens in the AFTER_INSERT handler.
MENU_ACTION:("item01", "item02")
You associate a consoleField with an SQL table column by setting the consoleField property SQLColumnName; and you must set the consoleField property dataType, as noted in ConsoleField Properties and Fields.
> 25
= 'Sarasota'
AGE > 28 AND CITY = 'Sarasota'
As shown, EGL places the operator AND between each clause that the user provides.
The next table shows valid user input and the resulting clause. The phrase simple SQL types refers to SQL types that are neither structured nor LOB-like types.
Symbol | Definition | Supported data types | Example | Resulting clause (for a character column named C) | Resulting clause (for a numeric column named C) |
---|---|---|---|---|---|
= | Equal to | Simple SQL Types | =x, ==x | C = 'x' | C = x |
> | Greater than | Simple SQL Types | >x | C > 'x' | C > x |
< | Less than | Simple SQL Types | <x | C < 'x' | C < x |
>= | Not less than | Simple SQL Types | >=x | C >= 'x' | C >= x |
<= | Not greater than | Simple SQL Types | <=x | C <= 'x' | C <= x |
<> or != | Not equal to | Simple SQL Types | <>x or !=x | C != 'x' | C != x |
.. | Range | Simple SQL Types | x.y or x..y | C BETWEEN 'x' AND 'y' | C BETWEEN x AND y |
* | Wildcard for String (as described in next table) | CHAR | *x or x* or *x* | C MATCHES '*x' | not applicable |
? | Single character wildcard (as described in next table) | CHAR | ?x, x?, ?x?, x?? | C MATCHES '?x' | not applicable |
| | Logical Or | Simple SQL Types | x|y | C IN ('x', 'y') | C IN (x, y) |
The equal sign (=) can mean IS NULL; and the not-equal sign (!= or <>) can mean IS NOT NULL.
A MATCHES clause results from the user's specifying one of the wildcard characters described in the next table.
Symbol | Effect |
* | Matches zero or more characters. |
? | Matches any single character. |
[ ] | Matches any enclosed character. |
- (hyphen) | When used between characters inside brackets, a hyphen matches any character in the range between and including the two characters. For example, [a-z] matches any lowercase letter or special character in the lower case range. |
^ | When used in brackets, an initial caret matches any character not included within the brackets. For example, [^abc] matches any character except a, b, or c. |
\ | Is the default escape character; the next character is a literal. Allows any of the wildcard characters to be included in the string without having the wildcard effect. |
Any other character outside of brackets | Must match exactly. |
Related concepts
Console user interface
Related reference
EGL library ConsoleLib
ConsoleUI parts and related variables
ConsoleUI screen options for UNIX
Text UI program in EGL source format
Related tasks
Creating an interface with ConsoleUI