basic.%rdhex

C Function/BASIC Program, Releases: AP/Unix

Reads a Unix file and translates to hexadecimal.

Syntax

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

Description

reads the number of bytes designated by 'size' into 'variable' from the file specified by 'file.descriptor' returned by a previous call to '%open()', '%creat()' or 'dup()' converting each byte into two ASCII hexadecimal characters.

A string of a size at least equal to 2 * 'size' must have been assigned to 'variable' before the call by either an explicit assignment (e.g. buffer=space(1000)) or by the 'char' reserve statement, otherwise data will be truncated.

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

See Also

Command Name Type Description
basic.cfunction Definition Declare a list of C functions.
basic.cfunc Definition can be called from a Pick/BASIC program or subroutine in AP/DOS and AP/Unix implementations using a syntax similar to that of normal C.
basic.%creat C Function Creates new Unix file, or rewrites to existing file.
basic.%dup C Function Returns new file descriptor.
basic.%read C Function Reads from a Unix file.
basic.%whex C Function Writes to a Unix file, converting into binary.
basic.%open C Function Opens a Unix file for reading or writing.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.