#1: Working with bits in COBOL Author: semigeezer, Location: AtlantisPosted: Wed Nov 16, 2005 5:07 pm 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 X 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'
#2: Author: kolusu, Location: San JosePosted: Wed Nov 16, 2005 5:51 pm semigeezer,
You can actually usel language environment calls to perform bit checking and manipulation
#3: Author: semigeezer, Location: AtlantisPosted: Wed Nov 16, 2005 8:35 pm 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.
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...