# _CP_lock

_CP_lock is equivalent to the lock BASIC statement.

The variant of lock used depends upon the type parameter:

| Type | BASIC Statement |
| --- | --- |
| _CP_LOCK | lock expression |
| _CP_LOCK_W | lock expression else * return -1 |

## Syntax

```
int _CP_lock(int type, int expression)
```

## Description

This function returns -1 if
an error occurs. The error code is contained in _CP_errno.

## Example(s)

```
/* Sets basic lock 1. */
_CP_lock(_CP_LOCK,1);
```

## See also

- [C functions overview](https://d3codex.com/cfunctions/c-functions-overview/)
- [_CP_unlock](https://d3codex.com/cfunctions/cp-unlock/)
- [_CP_unlock_all](https://d3codex.com/cfunctions/cp-unlock-all/)

---
Source: https://d3codex.com/cfunctions/cp-lock/ - part of the D3Codex reference.
