gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] Re: INITIALIZE Question


From: Guenter . Sandner
Subject: [open-cobol-list] Re: INITIALIZE Question
Date: Thu Jun 2 23:33:10 2005

Hi Alain!

> If you change your compiler from *M*F* to
> *Acu* or *Acu* to *M*F* or others
> YOU CAN CHANGE SOMETINGS IN YOURS CODE

I fully agree!

But, look at this record

[code]
       01  MEM-RECORD PIC X(3226).
       01  RED-MEM-RECORD REDEFINES MEM-RECORD.
           05 MEM-LAST-I   PIC S9(4) COMP.
           05 MEM-MIN-DATE PIC S9(9) COMP.
           05 MEM-SUM-BEFORE-INITIAL-DATE.
              10 MEM-BEFORE-SUMOFC  PIC S9(14)V9(4) COMP-3.
              10 MEM-BEFORE-SUMOFD  PIC S9(14)V9(4) COMP-3.
           05 MEM-ARRAY.
              10 MEM-ARRAY-ELEMENT OCCURS 100.
                 15 MEM-VALUDATE    PIC S9(9) COMP.
                 15 MEM-SUMOFC      PIC S9(14)V9(4) COMP-3.
                 15 MEM-NUMOFC      PIC S9(9) COMP.
                 15 MEM-SUMOFD      PIC S9(14)V9(4) COMP-3.
                 15 MEM-NUMOFD      PIC S9(9) COMP.
[/code]

Instead of initializing the record with one statement:

[code]
         INITIALIZE RED-MEM-RECORD.
[/code]

I would have to initialize all the members of the record:
[code]
               INITIALIZE MEM-LAST-I
               MEM-BEFORE-SUMOFC
               MEM-BEFORE-SUMOFD.
               MOVE 1 TO I.
               GO TO DX-00000421T.
           DX-00000421.
               ADD 1 TO I.
           DX-00000421T.
               IF I GREATER 100 GO TO DX-00000427X.
               INITIALIZE MEM-VALUDATE (I)
               MEM-SUMOFC (I)
               MEM-NUMOFC (I)
               MEM-SUMOFD (I)
               MEM-NUMOFD (I).
               GO TO DX-00000421.

[/code]

This is a big change for a small peace of code.
I do not think the "INITIALIZE RED-MEM-RECORD" statement works as expected
(Cobol Standard ?)

Kind regards
Guenter

------------------------------
opencobol version:
------------------------------
cobc (OpenCOBOL) 0.30

------------------------------
os:
------------------------------
SunOS sstviesun1 5.10 Generic sun4u sparc SUNW,Sun-Fire-V440


------------------------------
code:
------------------------------

       ID DIVISION.
       PROGRAM-ID. QUERY.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.


       01  MEM-RECORD PIC X(3226).
       01  RED-MEM-RECORD REDEFINES MEM-RECORD.
           05 MEM-LAST-I   PIC S9(4) COMP.
           05 MEM-MIN-DATE PIC S9(9) COMP.
           05 MEM-SUM-BEFORE-INITIAL-DATE.
              10 MEM-BEFORE-SUMOFC  PIC S9(14)V9(4) COMP-3.
              10 MEM-BEFORE-SUMOFD  PIC S9(14)V9(4) COMP-3.
           05 MEM-ARRAY.
              10 MEM-ARRAY-ELEMENT OCCURS 100.
                 15 MEM-VALUDATE    PIC S9(9) COMP.
                 15 MEM-SUMOFC      PIC S9(14)V9(4) COMP-3.
                 15 MEM-NUMOFC      PIC S9(9) COMP.
                 15 MEM-SUMOFD      PIC S9(14)V9(4) COMP-3.
                 15 MEM-NUMOFD      PIC S9(9) COMP.


       PROCEDURE DIVISION.
       BEGIN-PGM.
                   INITIALIZE RED-MEM-RECORD.
         DISPLAY "MEM-LAST-I (1)=" MEM-LAST-I.
         INITIALIZE MEM-LAST-I.
         DISPLAY "MEM-LAST-I (2)=" MEM-LAST-I.
           STOP RUN.
------------------------------
output:
------------------------------

MEM-LAST-I (1)=+8224
MEM-LAST-I (2)=+0000








reply via email to

[Prev in Thread] Current Thread [Next in Thread]