Hi
Micro focus class overlapping moves as undefined.
http://documentation.microfocus.com:8080/help/topic/com.microfocus.eclipse.infocenter.visualcobol.eclipsewin/HRLHLHDPF60RU031.html?resultof=%22%42%59%54%45%2d%4d%4f%44%45%2d%4d%4f%56%45%22%20
Micro focus allow some control using byte-mode-move directive.
http://documentation.microfocus.com:8080/help/topic/com.microfocus.eclipse.infocenter.visualcobol.vs2012/HRCDRHCDIR8G.html?resultof=%22%42%59%54%45%2d%4d%4f%44%45%2d%4d%4f%56%45%22%20
basically when doing overlap move output can only be controlled using byte-mode-move
using this code
>>>>>>
01 WS-SOMEFIELD PIC X(26).
MOVE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" TO WS-SOMEFIELD
display "before WS-SOMEFIELD <", WS-SOMEFIELD, ">"
MOVE WS-SOMEFIELD(3:10) TO WS-SOMEFIELD(4:10)
display "After WS-SOMEFIELD <", WS-SOMEFIELD, ">"
>>>>>>
Without byte-mode-move
before WS-SOMEFIELD <ABCDEFGHIJKLMNOPQRSTUVWXYZ>
After WS-SOMEFIELD <ABCCCEFGGIJKKNOPQRSTUVWXYZ>
Press enter ....
Using byte-mode-move
before WS-SOMEFIELD <ABCDEFGHIJKLMNOPQRSTUVWXYZ>
After WS-SOMEFIELD <ABCCCCCCCCCCCNOPQRSTUVWXYZ>
Press enter ....
The output will change depending 32 or 64 bit or the underlying CPU used, moving overlapping items is truly undefined and should not be relied upon.
>>>>>>> moving the data backwards will work thou, just a possible work around
identification division.
program-id. Program1.
environment division.
configuration section.
data division.
working-storage section.
01 WS-SOMEFIELD PIC X(26).
01 ans pic x.
01 movelength pic 9(4) comp.
01 startfrom pic 9(4) comp.
01 startto pic 9(4) comp.
01 i pic 9(4) comp.
01 j pic 9(4) comp.
01 ptrStr pointer value null.
linkage section.
01 lkStr pic x any length.
procedure division.
main section.
main-010.
MOVE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" TO WS-SOMEFIELD
display "before WS-SOMEFIELD <", WS-SOMEFIELD, ">"
MOVE WS-SOMEFIELD(3:10) TO WS-SOMEFIELD(4:10)
display "After WS-SOMEFIELD <", WS-SOMEFIELD, ">"
*
* move backwards make sure copy okay,
* no validation of movelength as demo
*
MOVE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" TO WS-SOMEFIELD
move 10 to movelength
move 3 to startfrom
move 4 to startto
*
* Using pointers to make generic routine
*
set ptrStr to address of WS-SOMEFIELD
set address of lkStr to ptrStr
compute i = startfrom + movelength - 1
compute j = startto + movelength - 1
display "before WS-SOMEFIELD <", WS-SOMEFIELD, ">"
perform movelength times
move lkStr(i:1) to lkStr(j:1)
subtract 1 from j
subtract 1 from i
end-perform
display "after WS-SOMEFIELD <", WS-SOMEFIELD, ">"
display "Press enter ...."
accept ans
.
main-090.
goback.
end program Program1.
>>>>>>>>>
>>>>>>>output from above program
before WS-SOMEFIELD <ABCDEFGHIJKLMNOPQRSTUVWXYZ>
After WS-SOMEFIELD <ABCCCCCCCCCCCNOPQRSTUVWXYZ>
before WS-SOMEFIELD <ABCDEFGHIJKLMNOPQRSTUVWXYZ>
after WS-SOMEFIELD <ABCCDEFGHIJKLNOPQRSTUVWXYZ>
Press enter ....
>>>>>>>>>>>>>