-Zz compiler option to convert embedded spaces

0 Likes

Problem:

In the ACUCOBOL-GT User's Guide Version 7, Chapter 2.1.13, Miscellaneous Options, it states that -Zz can be used to convert spaces to numeric in the excerpt below. Does the -Zz option convert embedded spaces and trailing spaces as well as leading spaces in a USAGE DISPLAY numeric item to zeros?

-Zz   This option causes spaces in a USAGE DISPLAY numeric item to be treated as the value zero, and non-numeric data to be treated as numeric. It does this by treating the high-value half of each byte as "3" so as to bring all bytes in the variable within the range of 30 to 3F.

Resolution:

The following test program below demostrates that leading, trailing, and embedded spaces are all converted by utilizing the -Zz compiler option. The program was executed three times using the version 8.0.1 compiler and runtime. The following is a table that contains the inputs for each iteration and the corresponding outputs.

                       Entered             Result

                       ----------             --------                 

First               spacespace1 &n bsp;  1

Second         1spacespace     100

Third             1space1             101

It should be noted, however, that utilizing the -Zz compiler option can have adverse performance implications as noted in the same section of the documentation.

"-Zz" must be specified at compile time in order to prevent the optimizer from mis-constructing the program. Note that this option should be used only if you need it, because it causes less efficient programs to be produced.

       IDENTIFICATION DIVISION.

       PROGRAM-ID.          & nbsp;         ZzUsage.

       ENVIRONMENT DIVISION.

       CONFIGURATION SECTION.

       SPECIAL-NAMES.         &nbs p; 

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       DATA DIVISION.

       FILE SECTION.

       WORKING-STORAGE SECTION.

       01 my-var       pic 9(3) usage display.

       PROCEDURE DIVISION.

       Main-logic.          & nbsp;

           accept my-var at 0303.   

           evaluate my-var

               when 1

                    display "my-var = 1" at 0503

               when 100   

                    display "my-var = 100" at 0503

               when 101

                    display "my-var = 101" at 0503

               when other  

                    display "invalid value" at 0503         

           end-evaluate.     &nbsp ;  

           accept omitted.

           stop run.

Attachments:

ZzUsage.cbl

Old KB# 2708
Comment List
Related
Recommended