HEXIMAGE Function

Purpose

Returns a character string which contains the hexadecimal representation of the storage at a specified location.

Syntax

HEXIMAGE(p,n,c)

Parameters

p is a restricted expression that must have a locator type. Note that if it is OFFSET, it must have the AREA attribute. n is an expression that must have a computational type and is converted to Fixed Binary(31,0). c is an expression that is optional and must have CHARACTER (1) NONVARYING.

Description

HEXIMAGE returns a character string that is the hexadecimal representation of n bytes of storage at location p, whose length is one of the following.
  • 2 * n, when used as HEXIMAGE(p,n).
  • When using HEXIMAGE(p,n,c), with character c inserted between every set of eight characters in the output string, its length is (2 * n) + ((n - 1)/4).

Example

dcl s char (32) varying;

   s = 'The witch cast a terrible spell.';

    display (trim(length(s)));
    display (heximage(addr(s), length(s) + 2));
    display (heximage(addrdata(s), length(s), '+'));

Prints:

  • On Little-Endian platforms:
     32
    200054686520776974636820636173742061207465727269626C65207370656C6C2E
    54686520+77697463+68206361+73742061+20746572+7269626C+65207370+656C6C2E
  • On Big-Endian platforms:
    32
    002054686520776974636820636173742061207465727269626C65207370656C6C2E
    54686520+77697463+68206361+73742061+20746572+7269626C+65207370+656C6C2E

Note the leading fixed bin (15) length field 2000 vs 0020 as stored on the native architectures.

Restrictions

None.