# uerror() function

The uerror() function returns the error number that resulted from the
 previous inter-operating system command.

## Format

```
UERROR( )
```

## Description

If an inter-operating system command fails, a positive integer code indicating the reason for
 the failure is stored for access by the uerror() function. If the command is
 successful, the error code is zero.

 The uerror() function reports return status codes resulting from the last
 mvBASIC inter-operating system statement. Exceptions are the uexecute
 command, uwaitfor command, and the umessage command.

## Example(s)

The following example opens the \library\book1.txt file for reading or
 prints an error code if the OPEN was not successful.

```
FILENAME="c:\library\book1.txt"
UOPEN FILENAME FOR READ TO FILEDES ELSE
 PRINT "Unable to UOPEN ":FILENAME:"
 Code=":UERROR( )
 STOP
END
UREAD VAAR2 FROM FILEDES FOR 50 THEN
 LENGTH=LEN(VAR2)
 IF LENGTH=50 ELSE
 PRINT "Only able to read ":UERROR( ):" bytes."
 END
END ELSE
 PRINT "Unable to read ":FILENAME:"
 Code=":UERROR( )
END
UCLOSE FILEDES ELSE NULL
```

## See also

- [O/S interoperability commands and functions](https://d3codex.com/pickbasic-flashbasic/os-interoperability-commands/)
- [uclose command](https://d3codex.com/pickbasic-flashbasic/uclose-command/)
- [ucreate command](https://d3codex.com/pickbasic-flashbasic/ucreate-command/)
- [udelete command](https://d3codex.com/pickbasic-flashbasic/udelete-command/)
- [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/uerror-function/ - part of the D3Codex reference.
