Nolween_deadra
Nolween_deadra

Reputation: 3

cobol : how to use a copy on linux?

I would like to know how to use a COPY statement. I am on Linux and I use GnuCOBOL with Visual Studio.

I have already tried several things but nothing works...

Here is my code:

   identification division.
   environment division.
   data division.
       working-storage section.
       copy laCopy.

   procedure division.

       accept w-user-entry.
       display w-user-entry.
       stop run.

and my copy :

   identification division.
  *environment division.
  *data division.
       working-storage section.
       01 variable.
          05 w-entreeUser PIC X(100).
       
   procedure division.
       stop run
  * GOBACK
       .

Each time I get the following error message:

laCopy:1: Error: Invalid indicator '' at column 7

Upvotes: 0

Views: 385

Answers (2)

Κonstantinos Βekas
Κonstantinos Βekas

Reputation: 16

I think the problem is that you have cobol code in your copybook.

Your copybook should have only variable definitions and should be like this:

        01 variable.
          05 w-entreeUser PIC X(100).

As @Robert stated above in cobol you can use the 8th column onwards.

Upvotes: 0

Robert
Robert

Reputation: 8663

Cobol comes from the age of punch cards. The first seven columns in a line are reserved. I forgot what the first six are, but the 7th is used for (among other things), comments: If there is a * in that column, the line is commented out. Your code does not use exactly seven spaces at the beginning of the line.

This compiles for me:

       identification division.
       program-id. hello.

      *environment division.

       data division.
       working-storage section.
       01 variable.
          05 w-entreeUser PIC X(100).

       procedure division.
       display 'test'.
       stop run.
      *GOBACK

Upvotes: 2

Related Questions