IB Statements/hexasc

From CometWiki

Jump to: navigation, search

HEXASC function

Syntax: HEXASC(string-argument)

Discussion: The HEXASC function converts an ASCII hex string to its ASCII hex equivalent, character for character. The string-argument represents the string to be converted. The string-argument may be a string constant, a single-element string variable, a string array element, a string expression, or a string function.

The result of the HEXASC function contains twice as many characters as the string-argument (because each byte of the string-argument will be represented by 2 bytes in ASCII).

Note: The ASCHEX function provides the opposite function of HEXASC (ASCHEX converts an ASCII hex string to its equivalent ASCII value).

Example: VALUE$ = HEXASC(STR$)

In the above example, the value contained in string variable STR$ is converted to its ASCII hex equivalent; the result is stored in the variable VALUE$.

For example, if STR$ equals "COMET", then VALUE$ will equal "434F4D4554" (because the ASCII hex equivalent of "C" is "43", the ASCII hex equivalent of "O" is "4F", the ASCII hex equivalent of "M" is "4D", etc.).

Likewise, if STR$ equals "123", then VALUE$ will equal "313233" (the ASCII hex equivalents of the characters "1", "2", and "3").

Personal tools