# Interrupt Events

The test file supports events, automatically raised by funTEST while specified action occurs. These events are defined as a sub-programs with special label names and format:

```
*event(event-type{:args})
```

#### Parameter Description

<table data-full-width="true"><thead><tr><th width="133.33333333333331">Parameter</th><th width="115">Type</th><th>Options</th></tr></thead><tbody><tr><td>event-type</td><td>[string]</td><td>Event type to catch, see following section for supported events.</td></tr><tr><td>args</td><td>[string]</td><td>Optional arguments to specific event types.</td></tr></tbody></table>

Here is an example of how this looks like in a test file

<figure><img src="https://3835935664-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F10lD1MSN8sl0KAFokfI3%2Fuploads%2F3CHADjCFSdnz035naOJC%2Fimage.png?alt=media&#x26;token=860f1430-cde0-47e9-91c0-4335ddd5722d" alt=""><figcaption><p>Interrupt event defined in a test file</p></figcaption></figure>

{% hint style="info" %}
Event sub-programs acts like standard asynchronously called methods (by funTEST), they can have passed some argument and must have a #return. Make sure that defined event is outside the main program loop. Recommended location is at the end of the test-file.
{% endhint %}

## Event Types

### <mark style="color:blue;">prj-closing (Project closing)</mark>

Occurs before the test file is closed. The closing can be refused by the #return argument

0 = refuse to close the test file, continue normally&#x20;

(otherwise) = finish closing

### <mark style="color:blue;">prj-closed (Project closed)</mark>

Occurs after test-file has been closed. Any GUI (Operator interface) command is denied here.

### <mark style="color:blue;">oper-changed (Operator changed)</mark>

Occurs after a new user is logged in (when another user is already logged in).

### <mark style="color:blue;">run-at (Run at specified time)</mark>

```
run-at:<hour>{:<min>{:<sec>}})
```

This label will be called by funTEST at specified time in a day. Call is repeated every day at this time. The time can be specified by hour only or also by minutes and seconds.

### Examples

<table data-full-width="false"><thead><tr><th width="238">Label</th><th>Description</th></tr></thead><tbody><tr><td>*event(run-at:1)</td><td>Run at 01:00.</td></tr><tr><td>*event(run-at:13:30)</td><td>Run at 13:30.</td></tr><tr><td>*event(run-at:15:10:30)</td><td>Run at 15:10:30.</td></tr></tbody></table>

### <mark style="color:blue;">run-every (Run every interval)</mark>

```
run-every:<ms>{:<sec>{:<min>{:<hour>}}})
```

This label will be called by funTEST repeatedly, after specified interval elapses. Time is defined by a sum of all parameters. It is possible to define the interval for example by only one parameter - passing i.e. 150 seconds is equivalent to 2 minutes and 30 seconds and so on. The next call is ignored when previous call is not finished.

### Examples

<table data-full-width="false"><thead><tr><th width="238">Label</th><th>Description</th></tr></thead><tbody><tr><td>*event(run-every:5)</td><td>Run every 0,5 second.</td></tr><tr><td>*event(run-every:0:30)</td><td>Run every 30 second</td></tr><tr><td>*event(run-every:0:0:60)</td><td>*event(run-every:0:0:0:1)</td></tr></tbody></table>
