MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Working with bits in COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Wed Nov 16, 2005 5:07 pm    Post subject: Working with bits in COBOL Reply with quote

I'm certainly no COBOL expert and I realize that COBOL is not intended to be used for system programming types of tasks, but is there a way to address individual bits within a byte? For simply testing a bit, I've resorted to this horrible method, which works, but there must be a better COBOL-only solution... is there? And how would one set a bit on or off? I didn't find any binary operators.

              01  oucb.
                  05 oucboucb        pic x(4).
                  05 filler          pic x(33).
                  05 oucbomvs        pic x.
              01 Filler.
                  05 Bin-Merge.
                    10 Bin-Hi        pic value low-Value.
                    10 Bin-Low       pic X.
                  05 Binnum redefines bin-Merge pic s99 binary.
              01  X10-Data.
                02  pic x(16) value X'000000000000000000000000000000'.
                02  pic x(16) value X'101010101010101010101010101010'.
                02  pic x(16) value X'000000000000000000000000000000'.
                02  pic x(16) value X'101010101010101010101010101010'.
                02  pic x(16) value X'000000000000000000000000000000'.
                02  pic x(16) value X'101010101010101010101010101010'.
                02  pic x(16) value X'000000000000000000000000000000'.
                02  pic x(16) value X'101010101010101010101010101010'.
                02  pic x(16) value X'000000000000000000000000000000'.
                02  pic x(16) value X'101010101010101010101010101010'.
                02  pic x(16) value X'000000000000000000000000000000'.
                02  pic x(16) value X'101010101010101010101010101010'.
                02  pic x(16) value X'101010101010101010101010101010'.
                02  pic x(16) value X'000000000000000000000000000000'.
                02  pic x(16) value X'101010101010101010101010101010'.
                02  pic x(16) value X'000000000000000000000000000000'.
              01 X10 redefines x10-Data pic x(256).
       
               move oucbomvs to bin-low
               if x10((binnum + 1):1) NOT = x'10'
       
Back to top
View user's profile Send private message Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12368
Topics: 75
Location: San Jose

PostPosted: Wed Nov 16, 2005 5:51 pm    Post subject: Reply with quote

semigeezer,

You can actually usel language environment calls to perform bit checking and manipulation

Check this link

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CEEA3130/4.0?DT=20020625092930

Hope this helps...

Cheers

Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Wed Nov 16, 2005 8:35 pm    Post subject: Reply with quote

Great! Thanks. Seems a bit odd to me (no pun intended) that this isn't a built in part of COBOL, particularly since COBOL was developled when memory was so tight that every bit should have counted, but if this is what it takes, that'll do. Thanks again.
Back to top
View user's profile Send private message Visit poster's website
MikeBaker
Beginner


Joined: 04 May 2004
Posts: 96
Topics: 9

PostPosted: Thu Nov 17, 2005 1:50 am    Post subject: Reply with quote

Also have a look at http://www.simotime.com/cblbit01.htm

Years ago, I also came across another COBOL program which manipulated bits, and it sure seemed alot smaller than the Simotime one. Cannot remember the code though...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group