Skip to main content
Version: 6.x

ON statement

The ON statement adds an event handler.

Syntax

ON eventClause eventAction;

Description

The ON statement adds an event handler for the specified event.

Parameters

Examples

CLASS Sku;
name = DATA STRING[100] (Sku);

ON {
LOCAL changedName = BOOLEAN (Sku);
changedName(Sku s) <- CHANGED(name(s));
IF (GROUP SUM 1 IF changedName(Sku s)) THEN {
MESSAGE 'Changed ' + (GROUP SUM 1 IF changedName(Sku s)) + ' skus!!!';
}
}

CLASS Order;

CLASS Customer;
name = DATA STRING[50] (Customer);

customer = DATA Customer (Order);
discount = DATA NUMERIC[6,2] (Order);

ON LOCAL {
FOR CHANGED(customer(Order o)) AND name(customer(o)) == 'Best customer' DO
discount(o) <- 50;
}