IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

problem about MOVE statement


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
william51
Warnings : 1

New User


Joined: 06 Jul 2006
Posts: 31

PostPosted: Fri Mar 16, 2007 9:18 am
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Fri Mar 16, 2007 9:31 am
Reply with quote

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
View user's profile Send private message
william51
Warnings : 1

New User


Joined: 06 Jul 2006
Posts: 31

PostPosted: Fri Mar 16, 2007 10:12 am
Reply with quote

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
View user's profile Send private message
william51
Warnings : 1

New User


Joined: 06 Jul 2006
Posts: 31

PostPosted: Fri Mar 16, 2007 10:13 am
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Fri Mar 16, 2007 10:41 am
Reply with quote

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. icon_smile.gif
Back to top
View user's profile Send private message
william51
Warnings : 1

New User


Joined: 06 Jul 2006
Posts: 31

PostPosted: Fri Mar 16, 2007 10:44 am
Reply with quote

Thank you.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Fri Mar 16, 2007 10:50 am
Reply with quote

Your'e welcome. icon_smile.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Mar 16, 2007 10:59 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts z/vm installation problem All Other Mainframe Topics 0
Search our Forums:

Back to Top