Re: The MOVE problem



The standard requires subscripts of the sending item o be evaluated once at the
beginning of execution of the statement and of the receiving item immediately
before it gets its data. Pages 478-479 of the '02 Standard has:

***

Item identification for identifier-2 is performed immediately before the data is
moved to the respective data tem. If identifier-2 is a zero-length item, the
MOVE statement leaves identifier-2 unchanged.

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 result of the statement

MOVE a (b) TO b, c (b)

is equivalent to:

MOVE a (b) TO temp
MOVE temp TO b
MOVE temp to c (b)

where 'temp' is an intermediate result item provided by the implementor


***

Now having said that, the concept of "item identification" was new in the '02
Standard (as I recall) and although this EXACT same "smple" appears in the '85
Standard (with the "temp" data item), my memory is that many (most?) compilers
use "temp" as the subscript for the receiving item.

Page VI-103 of the '85 Standard had the rule

"Any length evaluation or subscripting associated with identifier-2 is
evaluated immediately before the data is moved to the respective data item."

and then has exaclty the example given above.


--
Bill Klein
wmklein <at> ix.netcom.com
"Roger While" <simrw@xxxxxxxxxxxx> wrote in message
news:fg7ne4$e4q$01$1@xxxxxxxxxxxxxxxxxxxx
IDENTIFICATION DIVISION.
PROGRAM-ID. MOVEX.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 AA.
03 A PIC 9 OCCURS 9.
01 CC.
03 C PIC 9 OCCURS 9.
01 B PIC 9.
PROCEDURE DIVISION.
MOVE "987654321" TO AA.
MOVE "123456789" TO CC.
MOVE 3 TO B.
MOVE A(B) TO B C(B).
DISPLAY CC.
DISPLAY B.
GOBACK.

What shouzld be displayed in various compatible modes?

Roger




.



Relevant Pages

  • Re: The MOVE problem
    ... The original question came from a "compiler writer" not from a programmer. ... Item identification for identifier-2 is performed immediately before the data ... MOVE a TO temp ... compilers use "temp" as the subscript for the receiving item. ...
    (comp.lang.cobol)
  • Re: The MOVE problem
    ... Thanks Bill, I thought you would come back with a definitive response. ... Item identification for identifier-2 is performed immediately before the data is moved to the respective data tem. ... MOVE a TO temp ... subscript for the receiving item. ...
    (comp.lang.cobol)
  • Re: appending to a char
    ... >>and there's no problem with the Athat's the subscript. ... > argue that the function side effect rule applies. ... > interpretation of all the edge cases.) ... > evaluation of fis affected by the definition of something else ...
    (comp.lang.fortran)