# on...goto statement

The on...goto statement transfers control
to the line within the FlashBASIC or BASIC program that begins with
the specified statement label, according to the positional value of
the expression referenced by *exp*. The syntax can
also be specified as on...go to...(allowing a space
between go and to).

## Syntax

```
on exp goto statement.label{,
 statement.label...}

on exp goto statement.label,...,
 statement.label,
 statement.label
```

## Description

The on...goto is identical to the on...gosub, except there
is no return required.

Note: If the *exp* evaluates to a number less than 1, or to a number
greater than the number of statement labels, then control passes to
the next executable statement following the on...goto.

## Example(s)

This is an indexed branch in
the single-line format.

```
on response goto 100,200,300,400,500
```
This is an indexed branch in multiline format.

```
on response goto 100,200,300,
400,500,600,
700,800,900
```

## See also

- [goto statement](https://d3codex.com/pickbasic-flashbasic/goto-statement/)
- [on...gosub statement](https://d3codex.com/pickbasic-flashbasic/on-gosub-statement/)
- [statement labels](https://d3codex.com/pickbasic-flashbasic/statement-labels/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [u01a2 user exit](https://d3codex.com/proc/u01a2-user-exit/)

---
Source: https://d3codex.com/pickbasic-flashbasic/on-goto-statement/ - part of the D3Codex reference.
