event | A case-insensitive string constant naming the event to trap. |
subtype | A case-insensitive string constant naming the specific type of event to trap. This may contain * and ? to wildcard-match the event's sub-type. |
Return: | EVENT returns a single event. |
The EVENT function returns a trigger event, which may be used within the WHEN workflow service or the WAIT and NOTIFY actions.
Example:
IMPORT STD;
MyEventName := 'MyFileEvent';
MyFileName := 'test::myfile';
IF (STD.File.FileExists(MyFileName),
STD.File.DeleteLogicalFile(MyFileName));
//deletes the file if it already exists
STD.File.MonitorLogicalFileName(MyEventName,MyFileName);
//sets up monitoring and the event name
//to fire when the file is found
OUTPUT('File Created') : WHEN(EVENT(MyEventName,'*'),COUNT(1));
//this OUTPUT occurs only after the event has fired
afile := DATASET([{ 'A', '0'}], {STRING10 key,STRING10 val});
OUTPUT(afile,,MyFileName);
//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));