×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Need to understand cobol code

Need to understand cobol code

Need to understand cobol code

(OP)
Hi, I have no understanding of Cobol but got a program to understand so that I can implement similar logic in my database.

Can someone please help me with sharing what's happening at each line of the code below? There are two sections: One to convert from Base10 to 32 and vice versa.

Cobol code –


MYLP15-CONVERSION SECTION.

MOVE 0 TO LY15-RETURN-CODE
MOVE SPACES TO LY15-OUTPUT.
IF LY15-10TO32
PERFORM MYLP15-CONVERT-10TO32
END-IF.
IF LY15-32TO10
PERFORM MYLP15-CONVERT-32TO10
END-IF.


MYLP15-CONVERT-10TO32 SECTION.

MOVE LY15-INPUT-BASE10 TO LY15-NUMBER.

MOVE 0 TO LY15-I.
PERFORM
WITH TEST AFTER
UNTIL LY15-NUMBER NOT > 0
DIVIDE LY15-NUMBER BY 32
GIVING LY15-NUMBER
REMAINDER LY15-REMAINDER
MOVE LY15-OUTPUT TO LY15-SAVE
MOVE LY15-HEXNUMBER(LY15-REMAINDER + 1)
TO LY15-OUTPUT(1:1)
MOVE LY15-SAVE
TO LY15-OUTPUT(2:9)
END-PERFORM.

MYLP15-CONVERT-32TO10 SECTION.


MOVE 0 TO LY15-NUMBER.
MOVE 0 TO LY15-I.
MOVE LENGTH OF LY15-INPUT-BASE32 TO LY15-LEN.
PERFORM
WITH TEST AFTER
VARYING LY15-LEN FROM LY15-LEN BY -1
UNTIL LY15-INPUT-BASE32(LY15-LEN:1) GREATER THAN ' '
OR LY15-LEN = 0
END-PERFORM.
IF LY15-LEN = 0
MOVE 1 TO LY15-RETURN-CODE
ELSE
PERFORM
VARYING LY15-J FROM 1 BY 1
UNTIL LY15-J > LY15-LEN
OR LY15-RETURN-CODE NOT = 0
MULTIPLY LY15-NUMBER BY 32
GIVING LY15-NUMBER
PERFORM
WITH TEST AFTER
VARYING LY15-I FROM 1 BY 1
UNTIL LY15-HEXNUMBER(LY15-I) =
LY15-INPUT-BASE32(LY15-J:1)
OR LY15-I = 32
END-PERFORM
IF LY15-HEXNUMBER(LY15-I) NOT =
LY15-INPUT-BASE32(LY15-J:1)
MOVE 2 TO LY15-RETURN-CODE
ELSE
COMPUTE LY15-NUMBER = LY15-NUMBER + LY15-I - 1
END-IF
END-PERFORM
MOVE LY15-NUMBER TO LY15-OUTPUT-BASE10
END-IF.
MYLP15-CONVERSION-END SECTION.

EXIT.

RE: Need to understand cobol code

Hi,

I'd guess you're going to use VBA. Just write two VBA functions. Forget trying to decode a business language.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close