The following table provides examples for using the SEL operator. The SEL operator selects the right-most number of digits from operand1. The number of digits selected from operand1 is specified by operand2.
Command
Result
set A = B SEL 12
Variable definitions:
A = collect type, length = 10, start = 3
B = 1234567890123
1234567890123 SEL 12 = 234567890123 = 4567890123
Ten digits were selected starting at position 3.
set A = B SEL 5
The number of digits specified in operand2 is more than the number of digits in operand1.
B = 1234
1234 SEL 5 = 01234
The result contains all of the digits in operand1 with leading zeros as necessary.
set A = B SEL 1
Operand1 contains no digits (#) or is set to zero.
B = #
# SEL 1 = 0
The result is null padded with a zero. The SEL 1 adds a leading zero.
set A = B SEL C
Operand2 contains no digits or is set to zero.
B = 1234
C = #
1234 SEL # = 1234 SEL 0 = none
The result is none.
set A = B SEL 3
B = 120005
120005 SEL 3 = 005
The zeros are retained in the result.
set A = B SEL C
B = 1234567890123456
C = 99
1234567890123456 SEL 99 = 1234567890123456
Operand2 contains a number greater than 16, therefore a maximum of 16 digits is selected from operand1.