View previous topic :: View next topic
|
Author |
Message |
william51 Warnings : 1 New User
Joined: 06 Jul 2006 Posts: 31
|
|
|
|
I have code below
05 WS-O-CTL1 PIC X(04)
05 WS-O-CTL1 PIC X(04)
05 WS-O-CTL1 PIC X(04)
05 WS-O-CTL1 PIC X(04)
MOVE WS-O-CTL1(1:2) TO WS-O-CTL1(3:2).
MOVE '00' TO WS-O-CTL1(1:2).
MOVE WS-O-CTL2(1:3) TO WS-O-CTL2(2:3).
MOVE '0' TO WS-O-CTL2(1:1).
MOVE WS-O-CTL3(1:3) TO WS-O-CTL3(2:3).
MOVE '0' TO WS-O-CTL3(1:1).
MOVE '0000' TO WS-O-CTL4.
before process this code,the value is
WS-O-CTL1 : 18
WS-O-CTL2 : 100
WS-O-CTL3 : 694
WS-O-CTL4 : 000
WS-O-CTL1(2:3) : 8
WS-O-CTL2(2:3) : 00
WS-O-CTL3(2:3) : 94
after press,the value is
WS-O-CTL1 : 0018
WS-O-CTL2 : 0111
WS-O-CTL3 : 0666
WS-O-CTL4 : 0000
WS-O-CTL2 and WS-O-CTL3 is not the value i want,what cause that?
Why WS-O-CTL1 is correct? |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Since the source and destination bits (partially) are similar for CTL2 and CTL3, you are getting the OP like that.
Corrections are welcome. |
|
Back to top |
|
|
william51 Warnings : 1 New User
Joined: 06 Jul 2006 Posts: 31
|
|
|
|
The system delete the spaces automatically,so i add space line here.
MOVE WS-O-CTL1(1:2) TO WS-O-CTL1(3:2).
MOVE '00' TO WS-O-CTL1(1:2).
MOVE WS-O-CTL2(1:3) TO WS-O-CTL2(2:3).
MOVE '0' TO WS-O-CTL2(1:1).
MOVE WS-O-CTL3(1:3) TO WS-O-CTL3(2:3).
MOVE '0' TO WS-O-CTL3(1:1).
MOVE '0000' TO WS-O-CTL4. |
|
Back to top |
|
|
william51 Warnings : 1 New User
Joined: 06 Jul 2006 Posts: 31
|
|
|
|
correct the definition
05 WS-O-CTL1 PIC X(04)
05 WS-O-CTL2 PIC X(04)
05 WS-O-CTL3 PIC X(04)
05 WS-O-CTL4 PIC X(04) |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
WS-O-CTL2 100B -- B for blank
MOVE WS-O-CTL2(1:3) TO WS-O-CTL2(2:3).
it works like this- this move will spawn 3 byte level moves.
Code: |
WS-O-CTL2(1:1) to WS-O-CTL2(2:1) --- WS-O-CTL2 is 110B
WS-O-CTL2(2:1) to WS-O-CTL2(3:1) --- WS-O-CTL2 is 111B
WS-O-CTL2(3:1) to WS-O-CTL2(4:1) --- WS-O-CTL2 is 1111
|
NOTE:
Value of your variable is changing after every elementary move.
Other results are explanable using the same techniqe.
Use a temp variable so as not to get in to such problem. |
|
Back to top |
|
|
william51 Warnings : 1 New User
Joined: 06 Jul 2006 Posts: 31
|
|
|
|
Thank you. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Your'e welcome. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
william51 wrote: |
WS-O-CTL2 and WS-O-CTL3 is not the value i want,what cause that? |
Standard overlapping move, programmers have been using it for almost 50 years to clear or initialize memory.
The MVC works byte for byte left to right. |
|
Back to top |
|
|
|