WHEN

action : WHEN( event [ ,COUNT( repeat ) ] ) ;

actionAny valid ECL Action to execute.
eventThe event that triggers action execution. This may be either the EVENT or CRON functions, EVENTNAME or the name of an EVENT (as a shorthand for EVENT(event,'*')), or any attribute defined with those functions.
COUNTOptional. Specifies the number of events to trigger instances of the action. If omitted, the default is unlimited (continuously waiting for another event to trigger another instance of the action), until the workunit is manually removed from the list of workunits being monitored by the scheduler.
repeatAn integer expression.

The WHEN service executes the action whenever the event occurs.

Example:

IMPORT STD;
IF (STD.File.FileExists('test::myfile'),
     STD.File.DeleteLogicalFile('test::myfile'));
     //deletes the file if it already exists
STD.File.MonitorLogicalFileName('MyFileEvent','test::myfile');
     //sets up monitoring and the event name
     //to fire when the file is found
OUTPUT('File Created') : WHEN(EVENT('MyFileEvent','*'));
     //this OUTPUT occurs only after the event has fired
     //may also be coded in this shorthand form:
     // OUTPUT('File Created') : WHEN('MyFileEvent');
afile := DATASET([{ 'A', '0'}], {STRING10 key,STRING10 val});
OUTPUT(afile,,'test::myfile');
     //this creates a file that the DFU file monitor will find
     //when it periodically polls
     //**********************************
EXPORT events := MODULE
    EXPORT dailyAtMidnight := CRON('0 0 * * *');
    EXPORT dailyAt( INTEGER hour,
                    INTEGER minute=0) :=
          EVENT('CRON',
               (STRING)minute + ' ' + (STRING)hour + ' * * *');
    EXPORT dailyAtMidday := dailyAt(12, 0);
END;
BUILD(teenagers) : WHEN(events.dailyAtMidnight);
BUILD(oldies) : WHEN(events.dailyAt(6));
BUILD(oldies) : WHEN(EVENT('FileDropped', 'x'));

See Also: EVENT, CRON, NOTIFY, WAIT