Skip to main content

[archive] Syntax error using "INDEXED BY"

  • January 14, 2008
  • 2 replies
  • 0 views

[Migrated content. Thread originally posted on 14 January 2008]

I had a syntax error crop up in a program I was compiling.

The statement definition read:

05 LOCN OCCURS 16 TIMES PIC X(6) INDEXED BY LCNT.

This produces a syntax error.

When I changed it to read:

05 LOCN OCCURS 16 TIMES INDEXED BY LCNT PIC X(6).

it was accepted without any problems.

From reading the Reference Manual, it appeared that either format was acceptable, but this does not appear to be the case.

Can anyone enlighten me as to why this difference should occur, given that the program containing the erroneous version has been in use prior to 30 July 2007 when I joined the organisation to program in ACUCOBOL to maintain and develop their various systems.

Many thanks for your assistance.

Geoffrey

2 replies

[Migrated content. Thread originally posted on 14 January 2008]

I had a syntax error crop up in a program I was compiling.

The statement definition read:

05 LOCN OCCURS 16 TIMES PIC X(6) INDEXED BY LCNT.

This produces a syntax error.

When I changed it to read:

05 LOCN OCCURS 16 TIMES INDEXED BY LCNT PIC X(6).

it was accepted without any problems.

From reading the Reference Manual, it appeared that either format was acceptable, but this does not appear to be the case.

Can anyone enlighten me as to why this difference should occur, given that the program containing the erroneous version has been in use prior to 30 July 2007 when I joined the organisation to program in ACUCOBOL to maintain and develop their various systems.

Many thanks for your assistance.

Geoffrey
If the previous COBOL programs were compiling 05 LOCN OCCURS 16 TIMES PIC X(6) INDEXED BY LCNT before you arrived it is possible that they were being compiled using a compiler option (there are several compiler options; such as -cv or -cp) that allow the ACUCOBOL-GT compiler to recognize COBOL syntax that other compilers recognize.

[Migrated content. Thread originally posted on 14 January 2008]

I had a syntax error crop up in a program I was compiling.

The statement definition read:

05 LOCN OCCURS 16 TIMES PIC X(6) INDEXED BY LCNT.

This produces a syntax error.

When I changed it to read:

05 LOCN OCCURS 16 TIMES INDEXED BY LCNT PIC X(6).

it was accepted without any problems.

From reading the Reference Manual, it appeared that either format was acceptable, but this does not appear to be the case.

Can anyone enlighten me as to why this difference should occur, given that the program containing the erroneous version has been in use prior to 30 July 2007 when I joined the organisation to program in ACUCOBOL to maintain and develop their various systems.

Many thanks for your assistance.

Geoffrey
If the previous COBOL programs were compiling 05 LOCN OCCURS 16 TIMES PIC X(6) INDEXED BY LCNT before you arrived it is possible that they were being compiled using a compiler option (there are several compiler options; such as -cv or -cp) that allow the ACUCOBOL-GT compiler to recognize COBOL syntax that other compilers recognize.