I want to take a break from writing about checking program correctness and to write instead about some new things we made available recently via PTFs.
we have added a new built-in function to provide an "unhex" capability. It is modeled after the base64decode8 etc. built-in functions, and in the Language Reference Manual, it would be described as
HEXDECODE decodes a source buffer from hex into a target buffer. It returns a FIXED BIN(31) value that indicates the number of bytes that are written into the target buffer.
p Specifies the address of the target buffer.
m Specifies the length in bytes of the target buffer. It must be computational and is converted to FIXED BIN(31).
q Specifies the address of the source buffer.
n Specifies the length in bytes of the source buffer. It must be computational and is converted to FIXED BIN(31).
If the address of the target buffer is zero, the number of bytes that would be written is returned. If the target buffer is not large enough, a value of -1 is returned. If the target buffer is large enough, the number of bytes that is written to the buffer is returned.
The source is presumed to be in EBCDIC or ASCII in accordance with the DEFAULT compiler option.
As an example, given
dcl s char(20) varying init('F3F1F4F1F5');
dcl t char(5);
dcl bytes fixed bin(31);
bytes = hexdecode( addr(t), length(t), addrdata(s), length(s) );
would result, when DEFAULT(EBCDIC) was in effect, in the variable bytes having the value 5 and the variable t having the value '31415'.
This new function requires a library PTF as indicated in the compiler PTF.
We will also provide a hexdecode8 function (that would presume the source is in UTF-8, and to be valid hex digits, this would mean it was also ASCII) if anyone would like it.
we have also added 3 additional new built-in functions:
These are just like the between built-in function except they are (partially) exclusive as indicated by their names. More specifically
BetweenExclusive( x, a, b) is equivalent to ( a < x ) & ( x < b )
BetweenLeftExclusive( x, a, b) is equivalent to ( a < x ) & ( x <= b )
BetweenRightExclusive( x, a, b) is equivalent to ( a <= x ) & ( x < b )
These functions are always inlined, and so no library PTF is needed to use them.