Like the check box widget, the single-selection widgets must be bound to a variable that represents their states. However, instead of a boolean variable, the single-selection widgets must be bound to an INT variable to represent the index of the currently selected option.
record singleSelectForm type ConsoleForm
{ formsize=[12,40] }
myRadio consoleRadioGroup
{name = "radio", bounds = [1,2,4,17]};
myCombo consoleCombo
{name = "combo", bounds = [7,2,1,15]};
myList ConsoleList
{name ="list", bounds = [9,2,2,18]};
end
radioValue, comboValue, listValue int = 2;
myWindow WINDOW {name="myWindow", position=[1,1]};
openWindow(myWindow);
myForm singleSelectForm{};
myForm.myCombo.items =
["Option One", "Option Two", "Option Three"];
myForm.myRadio.items =
["Option One", "Option Two", "Option Three"];
myForm.myList.items =
["one","two","three","four","five","six"];
displayForm(myForm);
openUI myForm
bind radioValue, comboValue, listValue
//event handlers go here
end
onEvent (ConsoleRadioGroup.SELECTION_CHANGED : "radio")
SysLib.writeStdout("Radio selected: "::radioValue);
onEvent (ConsoleCombo.SELECTION_CHANGED : "combo")
SysLib.writeStdout("Combo selected: "::comboValue);
onEvent(ConsoleList.SELECTION_CHANGED : "list")
SysLib.writeStdout("List selected: "::listValue);
A complete example of a Console UI program that uses a combo box widget and radio button group widget in this way follows:
package programs;
import forms.singleSelectForm;
program singleSelectTest type BasicProgram {}
radioValue, comboValue, listValue int = 2;
function main()
myWindow WINDOW {name="myWindow", position=[1,1]};
openWindow(myWindow);
myForm singleSelectForm{};
myForm.myCombo.items =
["Option One", "Option Two", "Option Three"];
myForm.myRadio.items =
["Option One", "Option Two", "Option Three"];
myForm.myList.items =
["one","two","three","four","five","six"];
displayForm(myForm);
openUI myForm
bind radioValue, comboValue, listValue
onEvent (ConsoleRadioGroup.SELECTION_CHANGED : "radio")
SysLib.writeStdout("Radio selected: "::radioValue);
onEvent (ConsoleCombo.SELECTION_CHANGED : "combo")
SysLib.writeStdout("Combo selected: "::comboValue);
onEvent(ConsoleList.SELECTION_CHANGED : "list")
SysLib.writeStdout("List selected: "::listValue);
end
end
end
package forms;
record singleSelectForm type ConsoleForm
{ formsize=[12,40] }
myRadio consoleRadioGroup
{name = "radio", bounds = [1,2,4,17]};
myCombo consoleCombo
{name = "combo", bounds = [7,2,1,15]};
myList ConsoleList
{name ="list", bounds = [9,2,2,18]};
end
When you run the EGL program in RCP mode, the user interface looks like this:


myForm.list1.multipleSelect = TRUE;
When multipleSelect is
set to false (as is the default) the value of the variable bound to
the widget
contains the index of the selected item. If the first item is selected,
the
variable contains the number 1; if the fifth item is selected, the
variable
contains the number 5. When multipleSelect is
set
to true, the variable contains a binary representation of the selected
items.
Each item in the list is assigned a multiple of two according to its
position:
the first item is 1, the second is 2, the third is 4, the fourth is
8, the
fifth is 16, the sixth is 32, and so on. The value of the variable
is the
sum of the values of all the selected items. For example, if only
the first
item is selected, the variable contains 1. If the first and second
items are
selected, the variable contains 3, which is the sum of the values
for the
two selected items. If the second, fifth, and sixth items are selected,
the
variable contains 50, or 2+16+32.