basic.%whex

C Function/BASIC Program, Releases: AP/Unix

Writes to a Unix file, converting into binary.

Syntax

byte.count=%whex(file.descriptor, variable)

Description

writes to the file specified by 'file.descriptor' returned by a previous call to '%open()', '%creat()' or 'dup()' a string of bytes resulting from converting the ASCII string variable into binary.

Two digits are converted into one eight bit binary character. variable is assumed to contain only hexadecimal characters '0' to '9', 'A' to 'F' or 'a' to 'f'. The function returns the number of bytes actually written or -1 if an error occurred. The size written to the file is the size of variable divided by 2. This function is the reverse of '%rdhex()'.

Example

* Write 'EOF'x'ff' on device
n=%whex( fd, oconv('EOF','mx'):'FF' )

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.%rdhex C Function Reads a Unix file and translates to hexadecimal.
basic.%write C Function Writes to a Unix file.
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.