COBOL

Does anyone know how to convert the ASCII letter 'A' to the Ascii value 65?

I would like to perform a calculation on the value of the letters entered without using evaluate of nested if statements.  I used to do this in Microfocus cobol using some sort of valueof statement.
LVL 2
kwolbert_ITAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
I don't see any support in Fujitsu Power Cobol for these types of conversions.  Have you tried the simplistic approach of just using a redefines, like:

01 conversion-area.
     02 ca-char picture x.
     02 ca-int redefines ca-char picture s9(2) binary.

Then just move the character to "convert" into the ca-char area, and get it's ascii value from ca-int.

~bp
kwolbert_ITAuthor Commented:
No I didn't try a redefine but I have now.  It returns a value of 40 no matter what.  

I attempted the same moving from pic x to pic 99 before and that didn't work.  Also 99 binary, s99, etc, etc, etc.  This shouldn't be complicated but for some reason I can't do it.  I remember doing this in Microfocus years ago and the coding escapes me.  It's a different language but why would Fujitisu incorporate that into it's abilities.  

Someday someone will look at my evaluate and post my code on thedailywtf.com.  
Bill PrewIT / Software Engineering ConsultantCommented:
Okay, sorry that wasn't useful.

Only other thought would be to try BINARY-CHAR UNSIGNED instead of BINARY in my example above.

Reading the docs it looks like my earlier test will allocate 2 bytes of storage for ca-int, which isn't going to work.  The docs seem to indicate that BINARY-CHAR UNSIGNED only allocates 1 byte, which is what we want.

~bp

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kwolbert_ITAuthor Commented:
01 conversion-area.
     02 ca-char                  pic x.
     02 ca-int redefines ca-char BINARY-CHAR UNSIGNED.

Worked like a charm!!!
Bill PrewIT / Software Engineering ConsultantCommented:
Excellent, glad I tossed that out there.  Thanks for the grade.

~bp
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Mainframe Languages

From novice to tech pro — start learning today.