$C2X

From m204wiki
Revision as of 13:18, 20 April 2013 by Alex (talk | contribs) (Automatically generated page update)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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