Change operators
Change operators - a set of operators that determine various types of property value changes.
Syntax
typeChange(propExpr)
Description
Change operators create properties which determine whether a given type of change has occurred for a certain property in the current session. They are context-dependent property operators and can be used inside expressions. Inside an event handler they switch to event mode and report changes since the previous occurrence of that event.
Parameters
-
typeChangeType of the change operator. It is specified by one of the keywords:
SET— value became non-NULL(wasNULLbefore)DROPPED— value becameNULL(was non-NULLbefore)CHANGED— value changed in any directionSETCHANGED— value changed and is now non-NULLDROPCHANGED— value either dropped or changed between two non-NULLvaluesSETDROPPED— value either set or dropped (aNULL/non-NULLboundary was crossed)
-
propExprThe expression whose change is checked.
Examples
CLASS Order;
CLASS Item;
quantity = DATA NUMERIC[14,2] (Item);
price = DATA NUMERIC[14,2] (Item);
sum = DATA NUMERIC[14,2] (Item);
posted = DATA BOOLEAN (Order);
status = DATA STRING[20] (Order);
// CHANGED — derived property recomputed when either operand changes (any → any non-equal)
sum(Item i) <- quantity(i) * price(i) WHEN CHANGED(quantity(i)) OR CHANGED(price(i));
// SET — fires only on NULL → value (initial assignment)
WHEN SET(posted(Order o)) DO
MESSAGE 'Order has been posted';
// SETCHANGED — value changed and is now non-NULL
WHEN SETCHANGED(status(Order o)) DO
MESSAGE 'Status is now: ' + status(o);
// DROPPED — fires only on value → NULL; PREV reads the value before clearing
WHEN DROPPED(status(Order o)) DO
MESSAGE 'Status was: ' + PREV(status(o));
// DROPCHANGED — value either dropped or replaced by another non-NULL value
CONSTRAINT DROPCHANGED(status(Order o))
MESSAGE 'Status cannot be cleared or changed once assigned';
// SETDROPPED — value crossed the NULL/non-NULL boundary in either direction
WHEN SETDROPPED(status(Order o)) DO
MESSAGE 'Status was assigned or cleared';