Re: Question regarding uniqueness




"Roger While" <simrw@xxxxxxxxxxxx> wrote in message
news:f8cm2c$vpa$00$1@xxxxxxxxxxxxxxxxxxxx
IDENTIFICATION DIVISION.
PROGRAM-ID. t11.
DATA DIVISION.
WORKING-STORAGE SECTION.

01 K525-AII-DRVR-RSTRT-DATA.
03 VARIABLE1 PIC X(8) VALUE SPACES.
03 K525-FRMT-FILE-ARRAY.
06 K525-FRMT-FILE-ARRAY-ROW
OCCURS 6 TIMES
ASCENDING KEY IS VARIABLE1.
09 VARIABLE1 PIC X(8) VALUE SPACES.
09 OTHER-DATA-ITEM PIC S9(5).
PROCEDURE DIVISION.
GOBACK.

This compiles with big iron and MF.
Why?

A data-name need not be unique unless it is referenced.

Current rules are at FDIS ISO/IEC 1989:2002 page 83,
8.4.1 Uniqueness of reference,
"Every user-defined name in a source element is assigned, by
the user, to name a resource that is to be used in solving a
data processing problem. (See 8.3.1.1.1, User-defined words.)
In order to use a resource, a statement shall contain a reference
that uniquely identifies that resource. In order to ensure
uniqueness of reference, a user-defined name may be qualified,
subscripted, or reference modified as described in the following
paragraphs."

One question that I considered is whether "VARIABLE1" in
the KEY phrase is unique, without explicit qualification.
According to the OCCURS clause, SR(3), this use of
"VARIABLE1" meets the requirement that it "shall be the name
of either the entry containing the OCCURS clause or an entry
subordinate to the entry containing the OCCURS clause" and,
therefore, need not be explicitly qualified; though it may be so
qualified under SR(2).

Of course, this is a stupid definition.
Any attempt in the PROC div to reference any field
would lead to a compile failure.

Not according to my tests with Micro Focus COBOL 3.2.
These statements work when inserted into the given code.
-----
move "a" to variable1 of k525-frmt-file-array-row (1)
display variable1 of k525-frmt-file-array-row (1)
-----
That is, these statements appear to meet the current standard
as well as the rules published in the LRM for that compiler.



.



Relevant Pages

  • Re: Question regarding uniqueness
    ... but, in fact, only that VARIABLE1 can not be referenced. ... in some compilers and added to COBOL 2002). ... In order to use a resource, a statement shall contain a reference ... without explicit qualification. ...
    (comp.lang.cobol)
  • Re: Question regarding uniqueness
    ... 03 VARIABLE1 PIC XVALUE SPACES. ... In order to use a resource, a statement shall contain a reference ... without explicit qualification. ... of either the entry containing the OCCURS clause or an entry ...
    (comp.lang.cobol)
  • Re: Question regarding uniqueness
    ... I believe that any compiler conforming to the '85 Standard needs to compile this ... "Uniaueness of reference. ... "ASCENDING KEY IS VARIABLE1" ...
    (comp.lang.cobol)
  • Re: Question regarding uniqueness
    ... Any attempt in the PROC div to reference any field ... would lead to a compile failure. ... As should every Cobol compiler. ... Both VARIABLE1 data items are subordinate to group items, ...
    (comp.lang.cobol)
  • Re: Question regarding uniqueness
    ... 03 VARIABLE1 PIC XVALUE SPACES. ... ASCENDING KEY IS VARIABLE1. ... The problem is the line right after that: duplicate definitions of VARIABLE1. ... and thus the duplication should cause a compile-time error. ...
    (comp.lang.cobol)