GUI ScreenIO for Windows

 ScreenIO.com


BITS-TO-BYTES and BYTES-TO-BITS

There are occasions where you need to encode data into the bits of a single byte, or extract a specific bit from a byte. These functions exist in some compilers and not others. We provide these functions for simplicity, and to assist in conversion from Legacy ScreenIO where these functions existed as SCR-BIBY and SCR-BYBI respectively.  Argument structures are similar but not identical to the legacy functions.

FUNC-BITS-TO-BYTES

This function takes an array of 1 character fields and treats each as if it were a "bit", and packs each group of 8 such "bits" into a single byte. 

 

FUNC-BYTES-TO-BITS 

This function takes one or more Bytes and extracts each bit thereof into a separate 1 character field called a "bit.

 

In either Function, you must specify the NUMBER OF BITS. This will be the number of input bits for Bits-to-byte and the number of output bits for Bytes-to-bits. Failure to specify bits correctly may cause these functions to overlay adjacent working storage areas.  Calling with bit-count = zero is a fatal error.

The Bit fields contain low-values when they are "off", and any other value when they are "on". Bits extracted will contain a character "X" for the on state and low-value for the off state. 

The source field will not be changed.

These functions are not limited to a single byte, and will allow converting long strings of text into even longer strings of bit flags, and vise-versa.

Client/Server issues

This API will only run on the server.

Files

Files available to copy to your system:

Usage

     COPY WIN32API.
     COPY BITOPS.


     
* ------------------------: Call the FUNCTION.

           MOVE 8 TO BITOPS-BIT-COUNT

           MOVE my-bit-flags TO BITOPS-UNPACKED-DATA
           SET FUNCTION-BITS-TO-BYTES TO TRUE
           CALL 'GSWINAPI' USING WIN32API-PARMS
                                 BITOPS-BIT-COUNT
                                 BITOPS-UNPACKED-DATA
                                 BITOPS-PACKED-DATA
                                 WIN32API-D
                                 WIN32API-E
                                 WIN32API-F.

 

Parameters specific to this function

BITOPS-BIT-COUNT 

This field contains the number of bits that are involved.  Note that you never specify the number of bytes, only bits.  If you have 8 bits that you wish to pack into a single byte, you would specify 8 in this field.  Similarly if you had two bytes that you wished to expand into 16 individual bit flags you specify 16.

BITOPS-UNPACKED-DATA 

This field contains the "bits".  Each byte in the unpacked data represents one bit, and they are arranged in exactly the order they will fit into the byte, such that the first bit will fit into the high-order bit of the byte of packed data. (LEFT TO RIGHT)

This is an input field for Bits-to-bytes and an output field for Bytes-to-bits.

BITOPS-PACKED-DATA

This field specifies the packed date, the bytes.

This is an Output field for Bits-to-Bytes, and an Input field for Bytes-to-Bits.

WIN32API-PARMS - Used in all GSWINAPI calls

This argument is standard for all Calls to GSWINAPI. It is used to select the desired API or function, and to return the status of the operation.

WIN32API-RC

Used to return the status of a call to GSWINAPI.  A value of zero is a failure, any other value indicates success. 

WIN32API-ERROR-CODE

unused.

WIN32API-ERROR-TEXT

Plain-text error message that describes why the operation failed.  The only failure reason is bit count of zero.

WIN32API-A through WIN32API-F

The number of these present varies depending on how many arguments are used by the desired function.  These are not used, but must be present because this CALL requires seven arguments.


2000-2006 Norcom, all rights reserved 

TOC

Send feedback to Norcom