$C2X

From m204wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The $C2X function translates each byte within a character string into two-byte hexadecimal-equivalent characters. $C2X returns a character string that is twice as long as the original string. The maximum input length is 126 bytes. If the input length is more than 126 bytes, a null string is returned.

Syntax

The format for the $C2X function is:

$C2X(charstr)

where charstr is the input character string (either a %variable or a quoted literal)

Example 1

PRINT $C2X('YES')

results in this output:

E8C5E2

Example 2

This example produces a decimal to hexadecimal conversion:

PROCEDURE D2X B PRINT $C2X($BINARY($READ('Enter D2X decimal value'),31)) END END PROCEDURE

resulting in this output:

$$ENTER D2X DECIMAL VALUE <--- $READ prompt 64565 <--- User enters some decimal input 0000FC35 <--- Procedure prints output value in hexadecimal