%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.


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


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.


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().