# uclose command

The uclose command closes a file variable previously opened with the
 uopen command.

## Format

```
UCLOSE FileHandle THEN statement(s) ELSE statement(s)
```

## Description

The command fails if *FileHandle* is not valid. If an error occurs, the ELSE
 clause executes. If the uerror() function is called, the appropriate error
 code is returned.

## Example(s)

These statements open, and then close, the \books\chap1.txt file:

```
FileName="c:\books\chapt1.txt"
UOPEN FileName FOR READ TO FileHandle ELSE
 PRINT "Unable to open ":FileName
 STOP
END
UCLOSE FileHandle ELSE
 STOP
END
```

## See also

- [O/S interoperability commands and functions](https://d3codex.com/pickbasic-flashbasic/os-interoperability-commands/)
- [ucreate command](https://d3codex.com/pickbasic-flashbasic/ucreate-command/)
- [udelete command](https://d3codex.com/pickbasic-flashbasic/udelete-command/)
- [uerror() function](https://d3codex.com/pickbasic-flashbasic/uerror-function/)
- [uexecute command](https://d3codex.com/pickbasic-flashbasic/uexecute-command/)
- [ulock command](https://d3codex.com/pickbasic-flashbasic/ulock-command/)
- [ulseek() function](https://d3codex.com/pickbasic-flashbasic/ulseek-function/)
- [umessage command](https://d3codex.com/pickbasic-flashbasic/umessage-command/)
- [uopen command](https://d3codex.com/pickbasic-flashbasic/uopen-command/)
- [uread command](https://d3codex.com/pickbasic-flashbasic/uread-command/)
- [ureadline() function](https://d3codex.com/pickbasic-flashbasic/ureadline-function/)
- [usystem() function](https://d3codex.com/pickbasic-flashbasic/usystem-function/)
- [uwaitfor command](https://d3codex.com/pickbasic-flashbasic/uwaitfor-command/)
- [uwrite command](https://d3codex.com/pickbasic-flashbasic/uwrite-command/)

---
Source: https://d3codex.com/pickbasic-flashbasic/uclose-command/ - part of the D3Codex reference.
