# inputtrap...gosub statement

The inputtrap...gosub statement, using
the *str.exp*, sets up an automatic computed gosub based on the next input @ statement
data. The position of the character in the string expression corresponds
to the position of the statement label in the list. This acts as a
trap that causes a gosub on all subsequent input @ statements.

## Syntax

```
inputtrap str.exp gosub statement.label{,statement.label...}
```

## Parameter(s)

| str.exp | An expression evaluating to characters to be searched for in the input. |
| --- | --- |
| statement.label | statement label to be branched to. |

## Description

Upon return from a gosub specification, execution continues at the statement
following the inputtrap statement, not the input @ statement.

inputtrap must
precede its associated input @ statement. Only
one inputtrap statement can be active at any time.

## Example(s)

```
inputtrap "abcd" gosub 10,20,30,40
input @(5,5):x
stop
10 print "You entered a"
return
20 print "You entered b"
return
30 print "You entered c"
return
40 print "You entered d"
return
```

## See also

- [input statement](https://d3codex.com/pickbasic-flashbasic/input-statement/)
- [inputerr statement](https://d3codex.com/pickbasic-flashbasic/inputerr-statement/)
- [inputnull statement](https://d3codex.com/pickbasic-flashbasic/inputnull-statement/)
- [inputtrap...goto statement](https://d3codex.com/pickbasic-flashbasic/inputtrap-goto-statement/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)

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