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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to compare or set to ASCII values or equivalents ? 1

Status
Not open for further replies.

Doylet

Programmer
Jan 31, 2001
30
0
0
US
In Basic we use A=Chr$(25) or B=ASC(...) to work with the ASCII equivalent of each character for string handling.

How do you do that in Cobol? ==================
learning & sharing
 
Some COBOLs have an intrinsic function. If yours doesn't, you could define a binary field and redefine it as an alpha field, something like this;

01 ASCII-VALUE PIC 9(4) BINARY VALUE ZEROS.

01 REDEFINES ASCII-VALUE.
05 PIC X.
05 CHAR-VALUE PIC X.

In your code, if you MOVE the character in question to CHAR-VALUE, it's ASCII equivalent will be in ASCII-VALUE. Of course, this also works with EBCDIC, but EBCDIC-VALUE might be a better name in that case. Betty Scherber
Brainbench MVP for COBOL II
 
Hi,
You can use hexadecimal definitions to easily accomodate any character:
01 char-a pic x value h"41".
01 esc pic x value h"1b".
01 nullchar pic x value h"00".
Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top