1

There is an example of how SHIFT-OUT and SHIFT-IN might be used from IBM Enterprise COBOL Language Reference:

DATA DIVISION.
WORKING-STORAGE.
01 DBCSGRP.
     05 SO PIC X.
     05 DBCSITEM PIC G(3) USAGE DISPLAY-1.
     05 SI PIC X.
   .
   .
   .
PROCEDURE DIVISION.
     MOVE SHIFT-OUT TO SO
     MOVE G"<D1D2D3>" TO DBCSITEM
     MOVE SHIFT-IN TO SI
     DISPLAY DBCSGRP
<
Represents the shift-out control character (X'0E')
>
Represents the shift-in control character (X'0F')

I don't understand why we have to insert < and > into the G-literal content while we already have SHIFT-OUT/SHIFT-IN in SO/SI.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
Vuong
  • 37
  • 6

1 Answers1

0

It is the format of the G-literal (or N-literal with compiler option NSYMBOL(DBCS). It is the rules.

The shift-out/-in are not part of the literal itself, so the group-item needs to contain its own shift-out/-in for the DBCS characters to mean anything (in the case where the group-item is referenced).

The leading and trailing shift-bytes are needed since each DBCS character is made up of any pair of bytes with any value from X'00' through X'FF' and so could (and do) contain the hexadecimal values of the shift characters.

Since a DBCS literal can be used in the same places where a DBCS item can be used, for instance the NATIONAL-OF function, then a DBCS literal must obey the rules for its value to be correctly interpreted.

When writing the code in the compiler could they have made the shift-out/-in implicit? Well, they didn't. End of story.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
  • On a related topic, maybe you have some useful opinions: http://stackoverflow.com/q/1309909/120163 Thanks in advance for looking at it. – Ira Baxter Mar 16 '16 at 17:51
  • do u mean it is mix from DBCS and SBCS, so the DBCS has to declare SO/SI itself? btw why it does not uses G"0ED1D2D30F" instead G"" – Vuong Mar 17 '16 at 07:12
  • No. A mixed-literal would be an alphanumeric literal, with the shift-out/-in embedded. I mean the shift-out/-in in the literal are not part of the data. Since they are not part of the data and shift-out/-in are required for the bytes to be interpreted as DBCS, you need to make their presence specific. In this, `G"0ED1D2D30F"`, you have a mix of a hex-values with two values which are a pair to make a single character. Are you having to use DBCS, or is this an idle query? – Bill Woodger Mar 17 '16 at 08:04
  • If you happen to speak Japanese, the Enterprise COBOL manuals are available for download in that language, and perhaps are more explicit about things. – Bill Woodger Mar 17 '16 at 08:05
  • I will check. If your explain is true I will make it correct answer. Thanks you very much. – Vuong Mar 21 '16 at 04:14
  • @Vuong so to make your literal, it is `G''` where you replace the < and the > with the two "characters" which represent the hex values X'0E' and X'0F'. They are not part of the data represented by the literal, they are part of IBM's convention for defining the literal. Those characters could always be used in place of use of the SHIFT-OUT/SHIFT-IN special registers. Being a literal, the SHIFT-OUT/SHIFT-IN special registers can't be used in defining the G-literal. – Bill Woodger Mar 21 '16 at 06:37