# nxtkey statement

The nxtkey statement scans forward through a key file along a key
 path.

## Syntax

```
NXTKEY result FROM filevar,a.code,key,n THEN/ELSE
```

## Parameter(s)

| result | Returned variable containing the keys retrieved in a multi-attribute dynamic array. |
| --- | --- |
| filevar | Variable to which the data file has been opened. |
| a.code | String expression containing the a (algebraic) processing code located in the file-defining item that identifies the index to use. The index must have previously been created with create-index. |
| key | Beginning key value at which to begin the retrieval. |
| n | Number of keys to retrieve. |

## Description

This statement retrieves at most *n* keys. Fewer may be retrieved if
 end-of-file is reached.

 Repetitive use of this statement is allowed with the last key from the previous statement
 being supplied as the beginning key for the next statement.

 The ELSE clause is executed if the file is not a keyed file or if the specified a.code
 variable is invalid. If the ELSE clause executes, then SYSTEM(0) returns the error condition as:

| 0 | The file was not a keyed file. |
| --- | --- |
| 1 | The a.code variable was invalid. |

## See also

- [Cruising and zooming commands](https://d3codex.com/updateprocessor/cruising-and-zooming-commands/)
- [key statement](https://d3codex.com/pickbasic-flashbasic/key-statement/)
- [prvkey statement](https://d3codex.com/pickbasic-flashbasic/prvkey-statement/)
- [root statement](https://d3codex.com/pickbasic-flashbasic/root-statement/)
- [then/else statement blocks](https://d3codex.com/pickbasic-flashbasic/then-else-statement-blocks/)
- [verify-index command](https://d3codex.com/tcl/verify-index-command/)

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