Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : Introduction to External Program Interfaces : Using MEMPTR to reference external data : Reading and writing data : Manipulating bit values
 
Manipulating bit values
You can copy bit values up to the size of an ABL INTEGER from one INTEGER value to another. The statement to copy bit values to an INTEGER variable, PUT-BITS, has the following syntax:

Syntax

PUT-BITS( destination , start-position , count ) = integer-expression
This statement interprets an integer (integer-expression) as the sequence of bits representing the binary value of integer-expression. For example, if the value of integer-expression is 22, the bit sequence is 10110. The statement interprets the INTEGER variable, destination, as a sequence of bits and writes the sequence of bits from integer-expression into destination, starting at the specified bit position (start-position). The bit position in destination is counted from the low-order bit, where the first bit is bit one (1). If the value of integer-expression is too large to store in the specified number of bits, ABL stores the low-order count bits of integer-expression in the specified count bits within destination.
The function to return some number of bits from an INTEGER variable, GET-BITS, has the following syntax:

Syntax

GET-BITS( source , start-position , count )
This function returns the INTEGER that represents the value of the number of bits specified by count starting at the specified low-order bit position (start-position) within the INTEGER variable specified by source.
Thus, you can store bit values in MEMPTR variables and return bit values from MEMPTR variables by using the PUT-LONG statement and GET-LONG function to store and return the corresponding INTEGER expression that contains the bit pattern.