# release statement

The release statement clears locks on
items locked with a previous matreadu, readu, or readvu statement.

## Syntax

```
release {file.var,} {ID.exp}
```

## Parameter(s)

| file.var | Specifies the file containing the item to be unlocked. |
| --- | --- |
| ID.exp | Specifies the item to be unlocked. |

## Description

Review the following information regarding the release statement:

- You can use the release statement to release a lock, even if it is under a transaction.

- If file.var and ID.exp are both omitted, all items currently locked by the current process are unlocked.

- If ID.exp is specified without file.var, the default file variable is used.

## Example(s)

**Example 1**

 In the following example, an item is read from the customer file and locked.

- If a new name is entered, the name attribute is changed, a date stamp is placed in attribute 20, and the item is written, automatically clearing the item lock.

- If no name is entered, no write occurs, requiring the item lock to be cleared with the release statement.

```
 readu item from customer.file,item-ID then
 input name
 if name # ’’ then
 item<1>=name
 item<20>=date()
 write item on customer.file,item-ID
 end else
 release customer.file,item-ID
 end
 end
```

**Example 2**

```
 begin work
 for i = 1 to 100
 write i:space(100) on i
 next i
 for i = 1 to 100
 if mod(i,2) = 0 then
 readu xx from i
 end else
 read xx from i
 end
 if xx # i:space(100) then msg= "2 - failed read ":i; goto fail
 next i
 for i = 1 to 100 step 3
 release i
 next i

 crt "Now check the locks, then hit return to continue"; in i
 rollback work;* do a rollback instead
```

 Results:
```

 :list-locks (i

 Item Locks PIB# Lvl Hash Item-id Filename
 1623204 (0018C4A4) 1 1 00000032 2 %1806329804.16720a
 1623205 (0018C4A5) 1 1 00000033 3 %1806329804.16720a
 1623207 (0018C4A7) 1 1 00000035 5 %1806329804.16720a
 1623208 (0018C4A8) 1 1 00000036 6 %1806329804.16720a
 1623210 (0018C4AA) 1 1 00000038 8 %1806329804.16720a
 1623211 (0018C4AB) 1 1 00000039 9 %1806329804.16720a
 1623212 (0018C4AC) 1 1 0000021B 11 %1806329804.16720a
 1623213 (0018C4AD) 1 1 0000021C 12 %1806329804.16720a
```

## See also

- [Default File Variables](https://d3codex.com/pickbasic-flashbasic/default-file-variables/)
- [File variable](https://d3codex.com/pickbasic-flashbasic/file-variable/)
- [ID expression](https://d3codex.com/pickbasic-flashbasic/id-expression/)
- [matread statement](https://d3codex.com/pickbasic-flashbasic/matread-statement/)
- [matwrite statement](https://d3codex.com/pickbasic-flashbasic/matwrite-statement/)
- [readv statement](https://d3codex.com/pickbasic-flashbasic/readv-statement/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [unlock-group command](https://d3codex.com/tcl/unlock-group-command/)
- [unlock-item command](https://d3codex.com/tcl/unlock-item-command/)
- [writevu statement](https://d3codex.com/pickbasic-flashbasic/writevu-statement/)

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