Skip to content

ATH

ASCII to Hexadecimal

This string function converts a string containing ASCII characters into a hexadecimal code in half-byte representation, right justified. The valid ASCII characters are the numbers 0 through 9 and letters A through F. Periods, commas, and plus or minus signs are not permitted in the string expression.

ATH (string-value [,ERR=line-ref|,ERC=error-code])
string-value
is a string composed of the characters "0" through "9" and "A" through "F" ($30$ through $39$ and $41$ through $46$).
line-ref
is the program line number or label to branch to if this directive produces an error.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

Every two ASCII characters generate a single hexadecimal code, so that the resultant string is half as long as the input string. If an odd number of characters are used in string-value, the function assumes 0 is the first character in order to make an even-numbered string.

If string-value contains ASCII characters other than the valid characters (0 through 9 and A through F), an ERR=26 results.

This function allows the storage of integer numeric data in less bytes than its string representation.

The reverse of ATH is the HTA function.

ATH ("123456789ABCDEF")

returns the string $0123456789ABCDEF$.

ATH ("2A")

returns the string $2A$ which is the character “*”.

HTA function

From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF