Re: Setting A Hex Value in COBOL
- From: "Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 31 May 2007 12:30:30 +1200
"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 touched
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
a
X'E5'. The decimal equivalent is +229. Since the value of the field is
3-digits, will it still "fit" into the PIC X field? Would it look
something
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.
Yes, that will work fine. You will have hex '00E5' in CH-E5-BIN, x'E5' in
CH-E5...
Remember that CH-E5-BIN is a binary halfword (two bytes). Therefore,
although the value is 'three digits' it can be accommodated into a single
byte. In fact, any value up to 255 would be OK... (It is only 'three digits'
because you are thinking in decimal :-))
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?
I believe I have used exactly this in VS COBOL II for IBM mainframes. It
might depend on what compiler options were in force and, as I worked on many
different sites I can't be sure. Worth a try though.
Pete.
.
- Follow-Ups:
- Re: Setting A Hex Value in COBOL
- From: William M. Klein
- Re: Setting A Hex Value in COBOL
- References:
- Setting A Hex Value in COBOL
- From: gary
- Setting A Hex Value in COBOL
- Prev by Date: Re: The Relative Importance of Web Development
- Next by Date: Re: Basic structure 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
|