UNSPEC pseudovariable

The UNSPEC pseudovariable assigns a bit value directly to x; that is, without conversion.

The bit value is padded, if necessary, on the right with '0'B to match the length of x, according to Table 1.

Read syntax diagramSkip visual syntax diagram
>>-UNSPEC(x)---------------------------------------------------><

x
Reference.

If x is a VARYING or VARYING4 string, its length prefix is included in the returned bit string. If x is an area, its control information is included in the receiving field.

The pseudovariable is subject to the rules for the UNSPEC built-in function described in UNSPEC.

Note: Use of UNSPEC can affect the portability of your program.

Example

  dcl 1 Str1 nonasgn static,
        2 * fixed bin(15) littleendian init(16),  /* '1000'X */
        2 * char init('33'x),
        2 * bit init('1'b),
        2 Ba(4) bit init('1'b, '0'b, '1'b, '0'b),
        2 B3 bit(3) init('111'b),
        2 * char(0);
  dcl Bit_Str1 bit(size(Str1)*8);
  dcl Bit_Ba   bit(dim(Ba)*length(Ba(1)));
  dcl Bit_B3   bit(length(B3));

  Bit_Ba   = unspec(Ba);   /* result is scalar '1010'B not an array */
  Bit_B3   = unspec(B3);   /* '111'B                                */
  Bit_Str1 = unspec(Str1); /* '100033D7'B4 or
                              '100033'B4 ∥ '11010111'B             */