Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

quick question. XOR in RM/Cobol.

Status
Not open for further replies.

vonusito

Programmer
Nov 28, 2016
2
CO
Hello,

I work with RM/Cobol 7.03 and RM/Cobol 11, according to some sources i've checked it's not possible to do a "XOR" expression in cobol.

Hopefully one one you guys can help me with this. BTW sorry for my broken english, this is not my mother language.


I need to calculate an LCR(Hexadecimal) in Cobol.

ex. I need to take this string "01,50,1,T0501,78174,0,0,11,0,1,"

then do (0 XOR 1) = RES, do (RES XOR 1) = RES2, do (RES2 XOR ,) and continue for every character of the given string(commas included). The final result sould be an Hexadecimal value. According to the string source the result should be a "59".

Thanks in advance.

David L.



 
XOR can be expressed in terms of logical disjunction, conjunction, and negation (for example see here). You have those available in the subprogram library (C$LogicalAnd, etc); see the RM/COBOL User's Guide for more information.

Another way is to create a table of XOR results, and use the binary value of the bytes to do a lookup. See thread209-571499 where I demonstarte this technique.


Tom Morrison
Hill Country Software
 
Thank you very much,

Found the subprogram library for the XOR in the RM/guide and Works great. Now i feel bad for not searching first on the user guide. Amazingly not a single article, fórum, post i read mentioned this.

Thanks again for the quick reply.

David Lopez.
 
David, welcome to Tek-Tips.

Bit-wise boolean operations are/were not common in COBOL. So, proprietary solutions are created by the COBOL vendors prior to the standardization of bit data types and boolean operations in 2002. In RM/COBOL (which is built on the 1985 standard) we chose to use CALL rather than extend the COBOL language.

Tom Morrison
Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top