× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I came up with a solution.
Instead of trying to work with individual bits in a binary format, I used the decimal format to manipulate the bits, since I know how many bytes I am working with (1).
I should note I am only interested in setting the bits, not reading the bits.

Example:

01 WORK-AREA.
05 FIELD-OF-INDICATORS-2.
10 FILLER PIC X(01).
10 FIELD-OF-IND PIC X(01).
05 DEC-IND REDEFINES FIELD-OF-INDICATORS-2
PIC 9(04) BINARY.

01 BIT-VALUES.
05 BIT-1 PIC 9(04) BINARY VALUE 1.
05 BIT-2 PIC 9(04) BINARY VALUE 2.
05 BIT-3 PIC 9(04) BINARY VALUE 4.
05 BIT-4 PIC 9(04) BINARY VALUE 8.
05 BIT-5 PIC 9(04) BINARY VALUE 16.
05 BIT-6 PIC 9(04) BINARY VALUE 32.
05 BIT-7 PIC 9(04) BINARY VALUE 64.
05 BIT-8 PIC 9(04) BINARY VALUE 128.

...
PROCEDURE DIVISION
...

MOVE ZEROES TO DEC-IND.
IF SWITCH-1 = 'Y'
ADD BIT-8 TO DEC-IND
END-IF.
IF SWITCH-2 = 'Y'
ADD BIT-7 TO DEC-IND
END-IF.
IF SWITCH-3 = 'Y'
ADD BIT-6 TO DEC-IND
END-IF.

MOVE FIELD-OF-IND TO SOME-FIELD-TO-STORE-OR-USE.
...



Jason Abreu
Abreu Innovations, Inc.
jason.abreu@xxxxxxxxxxxxxxxxxxxx
http://www.abreuinnovations.com/

On 1/12/2011 3:17 PM, David Gibbs wrote:
Jason Abreu wrote:
Does anybody have experience with bit manipulation in COBOL?

This question would be more appropriate on the COBOL400-L list (http://lists.midrange.com/listinfo/cobol400-l).

david


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.