bug-gnucobol
[Top][All Lists]
Advanced

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

Re: [Bug-GnuCOBOL] COPY STATEMENT Differences with IBM Mainframe


From: Michael Potter
Subject: Re: [Bug-GnuCOBOL] COPY STATEMENT Differences with IBM Mainframe
Date: Wed, 1 Aug 2018 23:11:10 -0400

I heard back.

They said the code is not used anymore so the best guess is it is just junk.

On Mon, Jul 9, 2018 at 5:37 PM Michael Potter <address@hidden> wrote:
I am waiting to hear from the person who maintains this source on the mainframe with what errors/warnings they are getting.

I will post when I know.

On Mon, Jul 9, 2018 at 4:35 PM Simon Sobisch <address@hidden> wrote:

As Ron noted the level 01 in those copies must be changed to a deeper
level, otherwise an empty 01 level would be in the code as the copy
resolves to

       01 ws-vars1.
       01 cp-vars1.
            05 cp-var1 PIC X(16).

Ideally GnuCOBOL wouldn't error with

BAR1.CPY (1): error: syntax error, unexpected Literal, expecting
EXTERNAL or EXTERNAL-FORM or GLOBAL or IDENTIFIED

But with

BAR1.CPY (1): error: syntax error, unexpected level-number, expecting
EXTERNAL or EXTERNAL-FORM or GLOBAL or IDENTIFIED

[patches welcome]

But I'd say Micro Focus is wrong to compile with the changes Ron noted.
The copy statement

 01 ws-vars1   COPY BAR1 REPLACING ==01== BY ==03==.

 should resolve to

 01 ws-vars1
 03 cp-vars1.
 05 cp-var1 PIC X(16).

and GnuCOBOL is correct to say a period is missing here.

@Ron: I assume if you remove the NOWARNING option you get a warning
here, correct?

Simon


Am 09.07.2018 um 12:38 schrieb Ron Norman:
> The test case has problems with Micro Focus COBOL...
>
> cob -P -Ox -C "NOWARNING ODOSLIDE "   -k tstcpy.bat -o tstcpy
>     11 01 cp-vars1.
> * 217-S**                                                             
> (   0)**
> **    Preceding item at this level has zero length
>     15 01 cp-vars2.
> * 217-S**                                                             
> (   1)**
> **    Preceding item at this level has zero length
> cob64: error(s) in compilation: tstcpy.bat           
>
>
> If I correct as follows:
>        01 ws-vars1   COPY BAR1 REPLACING ==01== BY ==03==.
>
>        01 ws-vars2.  COPY BAR2 REPLACING ==01== BY ==03==.
>
> The output is:
> ws-vars1 LENGTH = 16
> ws-vars2 LENGTH = 16
> cp-vars1 LENGTH = 16
> cp-vars2 LENGTH = 16
> ws-vars3 LENGTH = 16
> ws-vars4 LENGTH = 16   
>
> With GnuCOBOL I get the following errors:
> cobc -Wall -std=default -debug -fstatic-call -fimplicit-init
> -frelax-syntax  -fmf-files -x -o tstcpy tstcpy.bat
> BAR1: 1: Error: syntax error, unexpected Literal, expecting EXTERNAL or
> GLOBAL
> BAR1: 2: Error: Level number must begin with 01 or 77
> BAR3: 2: Error: syntax error, unexpected Literal, expecting EXTERNAL or
> GLOBAL
> tstcpy.bat: 23: Error: 'cp-vars1' is not defined 
>
>
> On Sun, Jul 8, 2018 at 6:43 PM, Michael Potter <address@hidden
> <mailto:address@hidden>> wrote:
>
>     I stumbled on some mainframe code that is using COPY statements on
>     the same line as the 01 level tag.
>
>     I have found four different ways this code does this, but only one
>     works on GnuCOBOL.
>
>     In the code below, only the 4th one will compile on GnuCOBOL.
>
>     I don't have access to a IBM mainframe to tell me how this would
>     react on the MF.
>
>     How is this working on the mainframe?  Assuming it is.
>
>
>
>    address@hidden copy1]$ cat *cbl
>
>            IDENTIFICATION DIVISION.
>            PROGRAM-ID. foo.
>
>            ENVIRONMENT DIVISION.
>            CONFIGURATION SECTION.
>               SOURCE-COMPUTER.
>                  pi3 WiTH DEBUGGING MODE .
>
>            DATA DIVISION.
>            WORKING-STORAGE SECTION.
>
>               01 ws-vars1   COPY bar1.
>
>               01 ws-vars2.  COPY bar2.
>
>               01 ws-vars3   COPY bar3
>                  REPLACING ==01 cp-vars3.== BY ====.
>
>               01 ws-vars4.  COPY bar4
>                  REPLACING ==01 cp-vars4.== BY ====.
>
>            PROCEDURE DIVISION.
>               DISPLAY "ws-vars1 LENGTH = " LENGTH OF ws-vars1.
>               DISPLAY "ws-vars2 LENGTH = " LENGTH OF ws-vars2.
>               DISPLAY "cp-vars1 LENGTH = " LENGTH OF cp-vars1.
>               DISPLAY "cp-vars2 LENGTH = " LENGTH OF cp-vars2.
>               DISPLAY "ws-vars3 LENGTH = " LENGTH OF ws-vars3.
>               DISPLAY "ws-vars4 LENGTH = " LENGTH OF ws-vars4.
>
>                GOBACK.
>
>            END PROGRAM foo.
>
>           * --------------------------------------------------------------
>    address@hidden copy1]$ cat foo.cbl
>
>            IDENTIFICATION DIVISION.
>            PROGRAM-ID. foo.
>
>            ENVIRONMENT DIVISION.
>            CONFIGURATION SECTION.
>               SOURCE-COMPUTER.
>                  pi3 WiTH DEBUGGING MODE .
>
>            DATA DIVISION.
>            WORKING-STORAGE SECTION.
>
>               01 ws-vars1   COPY bar1.
>
>               01 ws-vars2.  COPY bar2.
>
>               01 ws-vars3   COPY bar3
>                  REPLACING ==01 cp-vars3.== BY ====.
>
>               01 ws-vars4.  COPY bar4
>                  REPLACING ==01 cp-vars4.== BY ====.
>
>            PROCEDURE DIVISION.
>               DISPLAY "ws-vars1 LENGTH = " LENGTH OF ws-vars1.
>               DISPLAY "ws-vars2 LENGTH = " LENGTH OF ws-vars2.
>               DISPLAY "cp-vars1 LENGTH = " LENGTH OF cp-vars1.
>               DISPLAY "cp-vars2 LENGTH = " LENGTH OF cp-vars2.
>               DISPLAY "ws-vars3 LENGTH = " LENGTH OF ws-vars3.
>               DISPLAY "ws-vars4 LENGTH = " LENGTH OF ws-vars4.
>
>                GOBACK.
>
>            END PROGRAM foo.
>
>           * --------------------------------------------------------------
>    address@hidden copy1]$ cat *.cpy
>              01 cp-vars1.
>                 05 cp-var1 PIC X(16).
>
>              01 cp-vars2.
>                 05 cp-var2 PIC X(16).
>
>              01 cp-vars3.
>                 05 cp-var3 PIC X(16).
>
>              01 cp-vars4.
>                 05 cp-var4 PIC X(16).
>
>    address@hidden copy1]$ cat *.bash
>
>     cobc foo.cbl
>
>     cobcrun foo
>
>
>
>
> --
> Cheers
> Ron Norman

reply via email to

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