# `TAN` — `TRAP RAISE`

## Contents

- `TAN` — Tangent
- `TESTEVENT` — Tests if an event has occurred
- `TRAP` — Traps errors
- `TRAP RAISE` — Clears the trap flag

## `TAN` — Tangent

Usage: `t=TAN(angle)`

Returns the tangent of `angle`, an angle expressed in radians.

To convert from radians to degrees, use the DEG function.

## `TESTEVENT` — Tests if an event has occurred

Usage: `t%=TESTEVENT`

Returns ‘True’ if an event has occurred, otherwise returns ‘False’. The event is not read by TESTEVENT - it may be read with `GETEVENT`, `GETEVENT32`, or `GETEVENTA32`.

Warning: it is recommended that you use either `GETEVENT32` or `GETEVENTA32` without `TESTEVENT` as `TESTEVENT` may use a lot of power, especially when used in a loop as will often be the case.

## `TRAP` — Traps errors

Section Contents

- Trapping data file commands
- Trapping file commands
- Trapping directory commands
- Trapping data entry commands
- Trapping graphics commands

Usage: `TRAP command`

`TRAP` is an error handling command. It may precede any of these commands:

#### Trapping data file commands

`APPEND`, `UPDATE`, `BACK`, `NEXT`, `LAST`, `FIRST`, `POSITION`, `USE`, `CREATE`, `OPEN`, `OPENR`, `CLOSE`, `DELETE`, `MODIFY`, `INSERT`, `PUT`, `CANCEL`

#### Trapping file commands

`COPY`, `ERASE`, `RENAME`, `LOPEN`, `LCLOSE`, `LOADM`, `UNLOADM`

#### Trapping directory commands

`MKDIR`, `RMDIR`

#### Trapping data entry commands

`EDIT`, `INPUT`

#### Trapping graphics commands

`gSAVEBIT`, `gCLOSE`, `gUSE`, `gUNLOADFONT`, `gFONT`, `gPATT`, `gCOPY`

For example, `TRAP FIRST`.

Any error resulting from the execution of the command will be trapped. Program execution will continue at the statement after the `TRAP` statement, but `ERR` will be set to the error code.

`TRAP` overrides any `ONERR`.

## `TRAP RAISE` — Clears the trap flag

Usage: `TRAP RAISE x%`

Sets the value of `ERR` to `x%` and clears the trap flag.

For a full explanation of the use of `RAISE`, see Runtime errors — Handling errors reported while running programs.