Re: Setting A Hex Value in COBOL
- From: "Rick Smith" <ricksmith@xxxxxxx>
- Date: Thu, 31 May 2007 01:22:08 -0400
"gary" <garyinri@xxxxxxxxx> wrote in message
news:%yj7i.172509$nh4.82579@xxxxxxxxxxxxxxx
I have to modify an old COBOL program which probably hasn't been toucheda
since the mid-90's. And it's probably been almost as long since I've
touched COBOL. Part of what happens in the program is the setting of some
printer control codes which are sent to some downstream printers in CICS.
The following snippet of code shows how some of the control codes are
currently being set. It seems pretty straightforward. For instance, the
redefinition of CH-FF-BIN with its value of +12 causes the CH-FF field to
contain X'0C. Simarly, CH-1D-BIN with its value of +29 causes the CH-1D
filed to contain a X'1D'.
01 CH-NL-BIN PIC S9(4) COMP VALUE +21.
01 FILLER REDEFINES CH-NL-BIN.
02 FILLER PIC X.
02 CH-NL PIC X.
01 CH-FF-BIN PIC S9(4) COMP VALUE +12.
01 FILLER REDEFINES CH-FF-BIN.
02 FILLER PIC X.
02 CH-FF PIC X.
01 CH-1D-BIN PIC S9(4) COMP VALUE +29.
01 FILLER REDEFINES CH-1D-BIN.
02 FILLER PIC X.
02 CH-1D PIC X.
01 CH-56-BIN PIC S9(4) COMP VALUE +86.
01 FILLER REDEFINES CH-56-BIN.
02 FILLER PIC X.
02 CH-56 PIC X.
01 CH-31-BIN PIC S9(4) COMP VALUE +49.
01 FILLER REDEFINES CH-31-BIN.
02 FILLER PIC X.
02 CH-31 PIC X.
My question is this. I need to add a field which would end up containing
X'E5'. The decimal equivalent is +229. Since the value of the field issomething
3-digits, will it still "fit" into the PIC X field? Would it look
like this?
01 CH-E5-BIN PIC S9(4) COMP VALUE +229.
01 FILLER REDEFINES CH-E5-BIN.
02 FILLER PIC X.
02 CH-E5 PIC X.
This is some old MVS COBOL II code. Is there actually a better way to be
performing this function? Is there anything like MOVE X'E5' to CH-E5?
Whether anything is better may be entirely subjective;
but two other methods come to mind, both of which
seem to have become available with VS COBOL II.
1. Symbolic characters (ANSI 85):
[Note that values given here are 1 greater than the
actual character.]
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
SYMBOLIC CHARACTERS
CH-NL IS 22
CH-FF IS 13
CH-1D IS 30
CH-56 IS 87
CH-31 IS 50
CH-E5 IS 230.
2. Hexadecimal literals (VS COBOL II extension):
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FILLER.
02 CH-NL PIC X VALUE X"15".
02 CH-FF PIC X VALUE X"0C".
02 CH-1D PIC X VALUE X"1D".
02 CH-56 PIC X VALUE X"56".
02 CH-31 PIC X VALUE X"31".
02 CH-E5 PIC X VALUE X"E5".
The use of symbolic characters may generate MVI
instructions and not require any working-storage.
This use of hexadecimal literals in working-storage
may generate MVC instructions; but use less
working-storage than the existing method. Extending
the existing method may be more consistent with
other programs in the system. These are the choices
I see.
.
- Follow-Ups:
- References:
- Setting A Hex Value in COBOL
- From: gary
- Setting A Hex Value in COBOL
- Prev by Date: Re: Setting A Hex Value in COBOL
- Next by Date: Re: Setting A Hex Value in COBOL
- Previous by thread: Re: Setting A Hex Value in COBOL
- Next by thread: Re: Setting A Hex Value in COBOL
- Index(es):
Relevant Pages
|