This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
dictionary:events:createevent [2019/08/05 15:29] James Sentman added history and optional handler param |
dictionary:events:createevent [2021/02/15 13:26] James Sentman [Passing Parameters To A Handler Example] |
||
---|---|---|---|
Line 16: | Line 16: | ||
**weekdays** (7 character string in the form of "-MTWTF-" use dashes for days not to execute)\\ | **weekdays** (7 character string in the form of "-MTWTF-" use dashes for days not to execute)\\ | ||
**handler** (string, name of the handler) If executing a script you can optionally specify the handler to call rather than just running the script. This value is ignored unless the event is to execute a script. | **handler** (string, name of the handler) If executing a script you can optionally specify the handler to call rather than just running the script. This value is ignored unless the event is to execute a script. | ||
+ | **parameter** A list of items to be optionally passed to the handler. Only valid if you are executing a handler in the script. The number of parameters in the list must be the same as expected by the handler. | ||
===Examples:=== | ===Examples:=== | ||
Line 29: | Line 30: | ||
create event "nightly" that executes script "going to bed" in 15 * minutes | create event "nightly" that executes script "going to bed" in 15 * minutes | ||
</code> | </code> | ||
+ | |||
+ | ==Passing Parameters To A Handler Example== | ||
+ | if you had a global script named “meal manager” with a handler named “mealLogger” like this: | ||
+ | <code> | ||
+ | on mealLogger( theName, theEvent) | ||
+ | write log theName & “ has had “ & theMeal | ||
+ | end doThing | ||
+ | </code> | ||
+ | |||
+ | and then created an event such as this: | ||
+ | |||
+ | <code> | ||
+ | create event “breakfast” that executes script “meal manager” handler “mealLogger" parameter {“Jamie”, “Breakfast”} in 10 * minutes | ||
+ | </code> | ||
+ | |||
+ | in 10 minutes you would see output in the log like: | ||
+ | |||
+ | **jamie has had breakfast** | ||
+ | |||
===History:=== | ===History:=== | ||
The optional “handler” parameter was added in XTension 9.4.21 | The optional “handler” parameter was added in XTension 9.4.21 |