# .r command (mvBase)

The .r command executes stack statements stored in a file
 item.

The .r (run) command is used in conjunction with the .c (copy) command to save frequently
 performed command procedures and recall them for execution. The .r command executes one or more
 stack statements that have been stored in a file item with the .c command. You can also load
 these statements into the stack, and then selectively execute them.

## Syntax

```
.r [dict] filename item-ID [(L)]
```

## Parameter(s)

| dict | Specifies the file dictionary. |
| --- | --- |
| filename | Specifies the name of the file. |
| item-ID | Identifies the item in the filename that contains the stored statements you want to execute. |
| L | Loads the statements in item-ID into the stack without executing them. |

 After each command executes, it becomes statement 1 in the stack.

 To stop executing the statements stored in the file item, press BREAK. Even though all of the
 statements in the file item have not been executed, they will all be stored in the stack.

## Executing Statements Stored in a File Item

This example executes the statements stored in item ORDER-REPORTS in the file
 TC:
```

>.R TC ORDER-REPORTS

SORT ORDERS BY DATE BY CUST-ID BREAK-ON QUARTER (P)

[The command is executed.]

SORT ORDERS BY DATE BY CUST-ID BREAK-ON MONTH (P)

[The command is executed.]

SORT ORDERS BY DATE BY CUST-ID BREAK-ON WEEK (P)

[The command is executed.]

>
```

 The system displays each statement stored in item ORDER-REPORTS before executing it. These
 statements are now part of the stack, with the last-executed statement as statement
 1.
```
>.L3
001 SORT ORDERS BY DATE BY CUST-ID BREAK-ON WEEK
002 SORT ORDERS BY DATE BY CUST-ID BREAK-ON MONTH
003 SORT ORDERS BY DATE BY CUST-ID BREAK-ON QUARTER
```

## Loading Statements from a File Item into the Stack

This example loads the statements from the item ORDER-REPORTS in the file TC into the
 stack:
```
>.R TC ORDER-REPORTS (L)
>
```

 You can now selectively execute any of the statements with the .X command.

## See also

- [Dot stack](https://d3codex.com/tcl/dot-stack/)
- [stack command](https://d3codex.com/tcl/stack-command/)
- [TCL stack](https://d3codex.com/tcl/tcl-stack/)
- [tcl-stack file](https://d3codex.com/systemfiles/tcl-stack-file/)

---
Source: https://d3codex.com/tcl/r-command-mvbase/ - part of the D3Codex reference.
