Return a hexadecimal string representation of a numeric value

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
string = %HEX(value[, magnitude])

Return value


A hexadecimal, uppercase ASCII digit string representation of value. (a)



The value to be converted to a hexadecimal, ASCII representation. (n)


(optional) A value that determines the number of characters in the returned string, as follows: (n)

1 = 2-character string

2 = 4-character string

4 = 8-character string

8 = 16-character string


%HEX converts a decimal data value to a 32-bit longword value.

If magnitude is not present or if it contains a value other than 1, 2, 4, or 8, the resulting string is eight characters long (if value can be represented in 32 bits) or sixteen characters long (if value cannot be represented in 32 bits).


The following code fragment compares data from two files. One has data stored in ASCII format, the other in hexadecimal.

if (%hex(ascval, 1) .eq. hexval) 

The code fragment below checks for a specific hexadecimal value in the ASCII data.

if (%hex(ascval, 1) .eq. 'F')