# %rdhex() function

The %rdhex() function reads the number
of bytes designated by (size * 2) into *var* from
the file specified in *file.descriptor*, converting
each byte into two ASCII hexadecimal characters.

## Syntax

```
n = %rdhex(file.descriptor, var, size)
```

## Parameter(s)

| file.descriptor | file.descriptor is returned by a previous call to %open(), %creat(), or %dup(). |
| --- | --- |
| var | Contains the 2-byte hexadecimal characters returned. A string at least twice the size of the number of bytes read must have been assigned to var before the call by either an explicit assignment (for example, buffer=space(1000)) or by the charreserve statement, otherwise data is truncated. |
| size | The number of (bytes * 2) to read. |

## Description

The function returns the number
of bytes actually read or -1 if an error occurred. If less than twice
the size of *size* bytes are returned, the content
of the trailing string is undefined, as is normal in C. This function
is the opposite of %whex().

## See also

- [%creat() function](https://d3codex.com/pickbasic-flashbasic/percent-creat-function/)
- [%dup() function](https://d3codex.com/pickbasic-flashbasic/percent-dup-function/)
- [%open() function](https://d3codex.com/pickbasic-flashbasic/percent-open-function/)
- [%read() function](https://d3codex.com/pickbasic-flashbasic/percent-read-function/)
- [%whex() function](https://d3codex.com/pickbasic-flashbasic/percent-whex-function/)
- [FlashBASIC C functions overview](https://d3codex.com/pickbasic-flashbasic/flashbasic-c-functions-overview/)
- [cfunction statement](https://d3codex.com/pickbasic-flashbasic/cfunction-statement/)

---
Source: https://d3codex.com/pickbasic-flashbasic/percent-rdhex-function/ - part of the D3Codex reference.
