Link to home
Start Free TrialLog in
Avatar of kwolbert_IT
kwolbert_ITFlag for United States of America

asked on

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.
Avatar of Bill Prew
Bill Prew

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
Avatar of kwolbert_IT

ASKER

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.  
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
01 conversion-area.
     02 ca-char                  pic x.
     02 ca-int redefines ca-char BINARY-CHAR UNSIGNED.

Worked like a charm!!!
Excellent, glad I tossed that out there.  Thanks for the grade.

~bp