For Programmers: Free Programming Magazines  


Home > Archive > Cobol > December 2006 > ODO and reference modification









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ODO and reference modification
Roger While

2006-12-06, 7:55 am

01 Z PIC 9 VALUE 4.
01 A.
03 B PIC X OCCURS 1 TO 8 DEPENDING ON Z.

MOVE A(1:6) .....

What is supposed to happen here ?

Roger


Michael Mattias

2006-12-11, 6:56 pm

"Roger While" <simrw@sim-basis.de> wrote in message
news:el6h0f$bbd$01$1@news.t-online.com...
> 01 Z PIC 9 VALUE 4.
> 01 A.
> 03 B PIC X OCCURS 1 TO 8 DEPENDING ON Z.
>
> MOVE A(1:6) .....
>
> What is supposed to happen here ?


What should happen is the programmer is disciplined. (He/she should have
moved A(1:Z) after testing for non-zero Z)

In a practical sense, I would say that after the MOVE the destination's
first 'Z' characters are reliable and the rest will be pot luck.







HeyBub

2006-12-11, 6:56 pm

Roger While wrote:
> 01 Z PIC 9 VALUE 4.
> 01 A.
> 03 B PIC X OCCURS 1 TO 8 DEPENDING ON Z.
>
> MOVE A(1:6) .....
>
> What is supposed to happen here ?
>
> Roger


If it were:

01 A PIC X(10).

MOVE A(1:20) ...

The compiler would probably raise a ruckus.

What happens in your case probably depends on your compiler - from
"unexpected" or "undefined" all the way to "heat death of the universe."

Seems like it would be trivial to test.


Rick Smith

2006-12-11, 6:56 pm


"Roger While" <simrw@sim-basis.de> wrote in message
news:el6h0f$bbd$01$1@news.t-online.com...
> 01 Z PIC 9 VALUE 4.
> 01 A.
> 03 B PIC X OCCURS 1 TO 8 DEPENDING ON Z.
>
> MOVE A(1:6) .....
>
> What is supposed to happen here ?


[J4 is meeting this w, so Bill may not be able to comment
until the end of the w.]

My best guess is: the EC-BOUND-REF-MOD exception
condition is set to exist.

Using FDIS, ISO/IEC 1989:2002,

Page 309, 13.16.36.3 General rules [OCCURS clause,
FORMAT 2],
"8) An alphanumeric group item, bit group item, national
group item, or strongly-typed group item that has an
entry subordinate to it that specifies the variable-table
format of the OCCURS clause is a variable-length data
item. When a variable-length data item is referenced,
the part of the table area used in the operation is
determined as follows:

a) If the data item referenced by data-name-1 is outside
the group, only that part of the table area that is
specified by the value of the data item referenced by
data-name-1 at the start of the operation will be used.
If there are no elementary data items defined between
the data description entry of the group data item
and the definition of the table specified by format 2 and
the value of the data item referenced by dataname-1
at the start of the operation is zero, the group data item
is a zero-length item.
...."

Page 478, 14.8.24.3 General rules [MOVE statement]
"1) ...
If identifier-1 is reference modified, subscripted, or is
a function-identifier, the reference modifier, subscript, or
function-identifier is evaluated only once, immediately
before data is moved to the first of the receiving operands.
The length of the data item referenced by identifier-1
is evaluated only once, immediately before the data is
moved to the first of the receiving operands. If identifier-1
is a zero-length item, it is as if literal-1 were specified
as the figurative constant SPACE.

The evaluation of the length of identifier-1 or identifier-2
may be affected by the DEPENDING ON phrase of the
OCCURS clause."

Page 93, 8.4.2.3.3 General rules [Reference-modification],
"5) Reference modification creates a unique data item that
is a subset of the data item referenced by identifier-1.

This unique data item is defined as follows:
....
c) The evaluation of length specifies the number of bit
positions or character positions of the data item to be
used in the operation. The evaluation of length shall
result in a positive nonzero integer. The sum of
leftmost-position and length minus the value one shall
be less than or equal to the number of positions in
the data item referenced by identifier-1. ...

If the evaluation of leftmost-position or length results
in a non-integer value or a value that references a
position outside the area of identifier-1, the
EC-BOUND-REF-MOD exception condition is set
to exist."

Page 394, 14.5.12.1.5 Exception-names and exception
conditions, Table 14, shows that EC-BOUND-REF-MOD
is a fatal exception.

Page 393, 14.5.12.1.2 Fatal exception conditions,
"5) If checking for the exception condition is not enabled,
the implementor defines whether or not execution will
continue, how it will continue, and how any receiving
operands are affected."



William M. Klein

2006-12-11, 6:56 pm

I was on vacation, not at J4.

Any way,

'85 Standard
- results are undefined

'02 Standard
- an exception condition (for out-of-range) is raised

IBM
- If SSRANGE is turned on, then a run-time error occurs. Otherwise, "you get
what you get"

Micro Focus
- V5 has a new "reference modification" directive. I haven't used it yet - but
I think it would also catch this (probably at run-time, but MAYBE at
compile-time)

Others
- ???

--
Bill Klein
wmklein <at> ix.netcom.com
"Rick Smith" <ricksmith@mfi.net> wrote in message
news:12ndt3d2g3jnh6e@corp.supernews.com...
>
> "Roger While" <simrw@sim-basis.de> wrote in message
> news:el6h0f$bbd$01$1@news.t-online.com...
>
> [J4 is meeting this w, so Bill may not be able to comment
> until the end of the w.]
>
> My best guess is: the EC-BOUND-REF-MOD exception
> condition is set to exist.
>
> Using FDIS, ISO/IEC 1989:2002,
>
> Page 309, 13.16.36.3 General rules [OCCURS clause,
> FORMAT 2],
> "8) An alphanumeric group item, bit group item, national
> group item, or strongly-typed group item that has an
> entry subordinate to it that specifies the variable-table
> format of the OCCURS clause is a variable-length data
> item. When a variable-length data item is referenced,
> the part of the table area used in the operation is
> determined as follows:
>
> a) If the data item referenced by data-name-1 is outside
> the group, only that part of the table area that is
> specified by the value of the data item referenced by
> data-name-1 at the start of the operation will be used.
> If there are no elementary data items defined between
> the data description entry of the group data item
> and the definition of the table specified by format 2 and
> the value of the data item referenced by dataname-1
> at the start of the operation is zero, the group data item
> is a zero-length item.
> ..."
>
> Page 478, 14.8.24.3 General rules [MOVE statement]
> "1) ...
> If identifier-1 is reference modified, subscripted, or is
> a function-identifier, the reference modifier, subscript, or
> function-identifier is evaluated only once, immediately
> before data is moved to the first of the receiving operands.
> The length of the data item referenced by identifier-1
> is evaluated only once, immediately before the data is
> moved to the first of the receiving operands. If identifier-1
> is a zero-length item, it is as if literal-1 were specified
> as the figurative constant SPACE.
>
> The evaluation of the length of identifier-1 or identifier-2
> may be affected by the DEPENDING ON phrase of the
> OCCURS clause."
>
> Page 93, 8.4.2.3.3 General rules [Reference-modification],
> "5) Reference modification creates a unique data item that
> is a subset of the data item referenced by identifier-1.
>
> This unique data item is defined as follows:
> ...
> c) The evaluation of length specifies the number of bit
> positions or character positions of the data item to be
> used in the operation. The evaluation of length shall
> result in a positive nonzero integer. The sum of
> leftmost-position and length minus the value one shall
> be less than or equal to the number of positions in
> the data item referenced by identifier-1. ...
>
> If the evaluation of leftmost-position or length results
> in a non-integer value or a value that references a
> position outside the area of identifier-1, the
> EC-BOUND-REF-MOD exception condition is set
> to exist."
>
> Page 394, 14.5.12.1.5 Exception-names and exception
> conditions, Table 14, shows that EC-BOUND-REF-MOD
> is a fatal exception.
>
> Page 393, 14.5.12.1.2 Fatal exception conditions,
> "5) If checking for the exception condition is not enabled,
> the implementor defines whether or not execution will
> continue, how it will continue, and how any receiving
> operands are affected."
>
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com