View previous topic :: View next topic
|
Author |
Message |
shammiullah
New User
Joined: 13 Jun 2005 Posts: 24
|
|
|
|
05 WS-VAR1 PIC X(5)
05 WS-VAR2 REDEFINES WA-VAR1 PIC 9(5).
PROCEDURE DIVISION
MOVE 'ABCDE' TO WS-VAR1.
now what is the value of WS-VAR1 and WS-VAR2 ? |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
ABCDE |
|
Back to top |
|
|
shammiullah
New User
Joined: 13 Jun 2005 Posts: 24
|
|
|
|
hi,
do u mean to say that both variables will display ABCDE.being a variable declared as 9(5),how a varB can display ABCDE as varA. . |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi,
No. I was answering the ques:
Quote: |
now what is the value of WS-VAR1 and WS-VAR2 ? |
DISPLAY will convert some numeric variables, so you can't determine what its value is.
But if you put the vaiable(s) in a data rec then use ispf edit to view it, you'll see "ABCDE". |
|
Back to top |
|
|
Hames
New User
Joined: 03 Oct 2005 Posts: 49
|
|
|
|
Hi shammiullah,
MOVE statement will move the value from one variable to another irrespective of the data type.
So that is why if display the numeric value also it displays ABCDE.
But if you compare the value or do any numeric computation on that variable then it will give error. |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
hi frnd,
In the above case it wont give any error instead it will give the garbage value in WS-VAR2. As per hames once any computation is attempted then u will receive error. |
|
Back to top |
|
|
mijanurit Currently Banned New User
Joined: 26 Aug 2005 Posts: 33 Location: bangalore
|
|
|
|
hi summy,
when we use "redefine"?
when we don't use two variable at same time. u initialized WS-VAR1(i.e alphanumeric), if u display it will show "ABCDE". but WS-VAR2 will contain garbage value. if u display WS-VAR2 it will show some garbage value.
try it in lab. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Guys,
That "garbage value" you talk about is still "ABCD" in memory. The so called "garbage" is created by the DISPLAY verb when it attempts to display the contents of WS-VAR2 as it was defined.
I'm not so sure WS-VAR2 will display as "garbage" in this case. Has anybody actually tried to DISPLAY WS-VAR2 containing "ABCDE"?
And remember, there's a difference between a variable "containing" a value and that same variable DISPLAYing as a value. For e.g.:
var-x pix s9(001) comp-3 value 4 will CONTAIN X'4C'. It will DISPLAY D. That's because the code generated by the DISPLAY verb unpacks the field before diplaying it. The unpack changes the X'4C' to an X'C4', which DISPLAYs as a "D". |
|
Back to top |
|
|
|