# BEGIN Reset Files and Variables

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

## Format

**BEGIN\[ \[ EXCEPT** **\]** *varlist **| \**** **\]**

***Where***:

*varlist*  An optional list of variables.

## Description

The **BEGIN** directive performs the following functions:

1\. Closes all Local files currently open. *(Global files remain open unless using BEGIN \*).*

Note:
In closing all files, the main console window will be reset if the ['WK'](https://manual.pvxplus.com/parameters/wk) system parameter is not on. The reset consists of dropping all windows and all non-global graphical user interface controls. In addition, the menu_bar is reset to its default "Enabled" state.

2\. Resets **PRECISION** to the default value of 2 (the value set in the ['PD'](https://manual.pvxplus.com/parameters/pd) system parameter).

3\. Clears local variables. (*Global variables are not affected unless using BEGIN \*.)*

```
(a) All variables if no varlist appears on directive
(b) Only those in varlist if no EXCEPT clause given
(c) All but those in varlist if EXCEPT clause present

See
Example.
```

4\. Sets **ERR**, **RET**, and **CTL** to zero.

5\. Clears **FOR**/**NEXT**, **GOSUB**/**RETURN**, **WHILE/WEND**, etc. stack.

6\. Resets pointer to the first **DATA** item in the program.

The **BEGIN \*** directive also closes all global files and clears all global variables including those defined using the [GBL](https://manual.pvxplus.com/functions/gbl) function.

Note:  
When executed within an object (in [Object Oriented Programming](https://manual.pvxplus.com/pxplus-user-guide/object-oriented-pxplus/introduction)), the BEGIN directive will clear all of the object's properties, along with standard variables, and will close any standard local files and files owned by the object.

*(The ability to use \* to clear all global files/variables was added in PxPlus v7.10.)*

## See Also

[CLEAR Reset Variables](https://manual.pvxplus.com/directives/clear)  
[RESET Reset Program State](https://manual.pvxplus.com/directives/reset)  
[START Restart Session](https://manual.pvxplus.com/directives/start)  
[ERR( ) Test Error Value](https://manual.pvxplus.com/functions/err)  
[CTL Control Code: Key to End Input](https://manual.pvxplus.com/variables/ctl)  
[RET Operating System's Last Error Code](https://manual.pvxplus.com/variables/ret)

## Example

The following examples are from step 3 above:

3(a) begin  
3(b) begin A3$,B3$,C3,D3  
3(c) begin except CST_ID$,TX_VAL,TX_TBL${all}
