# RETRY Re-Execute Failing Instruction

> Source: https://manual.pvxplus.com/directives/retry

## Format

**RETRY**

## Description

The **RETRY** directive returns control to the statement on which the last error transfer occurred. This allows you to take corrective action and retry the statement.

Use **\*RETRY** to emulate this directive in a statement reference. See **[Labels/Logical Statement References](https://manual.pvxplus.com/appendix/labels-logical-statement-references)**.

If an error occurs on a statement where you have used any of the **ERR=**, **DOM=** or **END=** options, or where you have used a **[SETERR](https://manual.pvxplus.com/directives/seterr)** directive, PxPlus does the following:

- Saves the statement number and directive where the error occurred (as a retry address).
- Passes control to the file option or **SETERR** statement reference to handle the error.
- Returns control to the **RETRY** directive using the retry address.

You can find the currently saved retry address or line reference in **TCB(11)**. PxPlus returns an Error #27: Unexpected or incorrect WEND, RETURN, or NEXT (i.e. no return address on an error) if it encounters a **RETRY** directive with no previous statement saved.

The saved statement number and directive are cleared by any of the following directives: **[BEGIN](https://manual.pvxplus.com/directives/begin)**, **[CLEAR](https://manual.pvxplus.com/directives/clear)**, **[LOAD](https://manual.pvxplus.com/directives/load)**, **[RESET](https://manual.pvxplus.com/directives/reset)** or **[START](https://manual.pvxplus.com/directives/start)**. You can also clear the retry address by executing a **[RUN](https://manual.pvxplus.com/directives/run)** directive with a program name specified. When you use it in a compound statement, the **RETRY** directive must be the final directive.

If you set the **'RR'** system parameter, PxPlus will also perform a reset for **RUN** directives. *(as of PxPlus version 4.20)*

## See Also

**[RESET Reset Program State](https://manual.pvxplus.com/directives/reset)**  
**[TCB( ) Return Task Information](https://manual.pvxplus.com/functions/tcb)**  
**['RR' Reset on RUN](https://manual.pvxplus.com/parameters/rr)**

## Example

```
0010 open (1)"CUSTFL"
0020 input (0,err=1000)"Enter customer number: ",C
0030 read (1,err=1010,key=str(C:"000000"))C$,N$
0040 print C$," ",N$
0050 stop
1000 print 'RB','LF',"Invalid customer. "; retry ! Ring bell, retry 0020
1010 print 'RB',"Cannot find customer: "; goto 0020

->run
Enter customer number: 123987
Cannot find customer:
Enter customer number: ABC
Invalid customer.
Enter customer number: 123456
123456 ABC MFG
```
