This function provides an easy way to set a certain bit in a value. It does not access any I/O, but rather provides a much easier way to set a bit than standard REXX functions do. The format of the function is:

return_value = RTBitSet( value, bit_position )

The value is in decimal with a range of 0 to 65535.

bit_position is the position of the bit which value is to be set. The right-most position (and therefore the least significant bit) is 0, the left-most (or most significant bit) position is 15.

return_value is the value returned after the bit has been set. Range is 1 to 65535.

There is no variable range checking, so you must insure that the right values are passed along in the function.

Example:

The code below illustrates the RTBitSet function.

SAY 'Setting bit position 0 of the value 254 results in ' || RTBitSet( '254', '0' )
SAY 'Setting bit position 1 of the value 0 results in ' || RTBitSet( '0', '1' )

Output:
Setting bit position 0 of the value 254 results in 255
Setting bit position 1 of the value 0 results in 2