Re: The MOVE problem
- From: "William M. Klein" <wmklein@xxxxxxxxxxxxxxxxx>
- Date: Tue, 30 Oct 2007 22:30:38 GMT
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
.
- Follow-Ups:
- Re: The MOVE problem
- From: Judson McClendon
- Re: The MOVE problem
- References:
- The MOVE problem
- From: Roger While
- The MOVE problem
- Prev by Date: Re: [OT] System Conversion - An Overview
- Next by Date: Re: COBOL to Java conversion
- Previous by thread: Re: The MOVE problem
- Next by thread: Re: The MOVE problem
- Index(es):
Relevant Pages
|