# PVSetEnvMode( ): Set Environment Variables

> Source: https://manual.pvxplus.com/c-library-file-io-routines/file-io-routines/setenvmode

## Format

intptr_t **APIDEF PVSetEnvMode**(**HPVKENV** *hEnv*, int *iFlag*, intptr_t *iValue*);

***Where:***

|  |  |
| --- | --- |
| *hEnv* | Handle to environment structure |
| *iFlag* | Selector of the environment variable to be modified<br>Can be one of the following constants:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| PV_BURST_MODE \| 1 \|<br>\| PV_DIRTY_READ \| 2 \|<br>\| PV_LOCK_MODE \| 3 \|<br>\| PV_READ_ONLY \| 4 \|<br>\| PV_MAX_MB \| 5 \| |
| *iValue* | Corresponding value for *iFlag:*<br>\|  \|  \|<br>\| --- \| --- \|<br>\| PVK_BURST_ON \| 1 \|<br>\| PVK_BURST_OFF \| 0 \|<br>\| PVK_DIRTY_ON \| 1 \|<br>\| PVK_DIRTY_OFF \| 0 \|<br>\| PVK_DONT_CHECK_LOCK \| 1 *(Don't check, never lock read records)* \|<br>\| PVK_CHECK_LOCK \| 2 *(Check for extracted records)* \|<br>\| PVK_CHECK_LOCK_NOWAIT \| 4 *(Check for extracted records, exit if locked)* \|<br>\| PVK_HDR_LOCK_NOWAIT \| 8 *(Don't wait for a locked header)* \|<br>\| PVK_READONLY_ON \| 1 \|<br>\| PVK_READONLY_OFF \| 0 \|<br>\| PV_MAX_MB \| *(Maximum size of file segment in MB, integer value 0 to 2000)* \| |

## Description

**PVK_SetEnvMode(** **)** is used to set the value of environment variables. If successful, the function returns the previous value of the modified environment variable.

If specified and *iValue* is not valid, ERR_BAD_TYPE(-5) is returned. Returns PV_ERROR(-1) on failure.

## Additional Notes

**PV_BURST_MODE**

Normal processing of a file involves locking each area of the file as it is read. Activating burst mode greatly reduces the number of locks issued against a file. With Burst mode set, the PXPIO routines lock the file header for either 50 file operations or three-tenths of a second, whichever occurs first. This decreases the number of times the file must be locked and the number of times that internal buffers may need to be reloaded.

**PV_DIRTY_READ**

Dirty Read mode of operation skips the normal file consistency checks. Dirty reads can speed file processing by reducing the number of locks issued against a file. However, this may result in inconsistent data should the file be updated while being read by the PXPIO routines.

**PV_LOCK_MODE**

The Lock Mode is used to control whether to check for locked/extracted records when reading and writing. The default setting is to ***not*** check for locked records for backwards compatibility with older versions of the PXPIO routines.

Note:  
This flag should normally be set to PVK_CHECK_LOCK when files are being updated concurrently by PxPlus and applications using the PXPIO routines. A setting of PVK_DONT_CHECK_LOCK will allow the PXPIO routines to read and write a record that is extracted in PxPlus. The remaining settings provide a quicker means of checking for a locked record or file header and will return immediately rather than retrying the lock.

**PV_MAX_MB**

The PV_MAX_MB setting is used to control the approximate size of a file in megabytes before additional segments are created. This setting is functionally equivalent to the 'MB' (mega-bytes) system parameter in PxPlus. Values for PV_MAX_MB must be in the range of 0 (zero) to two thousand (2000). The default is two thousand (2000). Specifying a value of 0 (zero) resets this parameter to its default.
