Value input (INPUT)
The value input operator creates an action that requests the user to input a value. The requested value can be an object of a built-in class (for example, a string, a number, a date, or a file) or an object of a custom class. The user can cancel the input, for example by pressing the Esc key on the keyboard.
Interactive input of a built-in class value runs in the editor of the form property whose change is being handled, so for most built-in classes this operator must be invoked from a property change event handler. Values of file classes and colors are entered through a separate dialog, so they can also be requested from other form event handlers, for example from a button.
Requested value
If an object of a built-in class is requested, the platform shows the user an input control matching that class, and the user enters it directly.
If an object of a custom class is requested, the user does not enter it directly but selects it from the class's selection form.
Offered values
The values offered to the user can be limited to a specific set, and that set can be narrowed further by a condition. For a built-in class, such a set is shown to the user as a list of suggestions during input; for a custom class, it limits the objects available for selection.
In addition, if the input is used to change a property, the offered values are by default further limited to those whose selection will not break any constraint existing in the system — the same way as in the dialog form of form opening. This limitation can be disabled if needed.
Common input capabilities
As with other value input operators, this operator allows to:
- specify initial object values
- specify main and alternative actions. The first is called if the input was successfully completed, the second if not (i.e. if the input was canceled).
- change a specified property
Language
The syntax of the value input operator is described by the INPUT operator.
Examples
changeCustomer (Order o) {
INPUT s = STRING[100] DO {
customer(o) <- s;
IF s THEN
MESSAGE 'Customer changed to ' + s;
ELSE
MESSAGE 'Customer dropped';
}
}
FORM order
OBJECTS o = Order
PROPERTIES(o) customer ON CHANGE changeCustomer(o)
;
testFile {
INPUT f = FILE DO { // requesting a dialog to select a file
open(f); // opening the selected file
}
}
sku = DATA Sku (OrderDetail);
// selecting an object of a custom class: offering skus by their name and keeping only those in stock
changeSku (OrderDetail d) {
INPUT s = sku(d) CHANGE LIST name(s) WHERE inStock(s);
}