COMPARE
COMPARE compares the z bytes of two buffers at the addresses x and y.
COMPARE returns a FIXED BINARY(31,0) value. It can be any of the following values:
- Zero
- The z bytes at the addresses x and y are identical.
- Negative
- The z bytes at x are less than those at y.
- Positive
- The z bytes at x are greater than those at y.
- x and y
- Expressions. Both must have the POINTER or OFFSET type. If OFFSET, the expression must be declared with the AREA qualification.
- z
- Expression. It is converted to size_t 1.
Example
dcl Result fixed bin;
dcl 1 Str1,
2 B fixed bin(31),
2 C pointer,
2 * union,
3 D char(4),
3 E fixed bin(31),
3 *,
4 * char(3),
4 F fixed bin(8) unsigned,
2 * char(0);
dcl 1 Template nonasgn static,
2 * fixed bin(31) init(16), /* ''X */
2 * pointer init(sysnull()
),
2 * char(4) init(''),
2 * char(0);
call plimove(addr(Str1), addr(Template), stg(Str1));
Result = compare(addr(Str1), addr(Template), stg(Str1)); /* 0 */
D = 'DSA ';
Result = compare(addr(Str1), addr(Template), stg(Str1)); /* 1 */
B = 15; /* '00000F00'X */
D = 'DSA ';
Result = compare(addr(Str1), addr(Template), stg(Str1)); /* -1 */