View previous topic :: View next topic
|
Author |
Message |
Pandian
New User
Joined: 22 Jun 2004 Posts: 1 Location: Chennai
|
|
|
|
Hai Friends,
Can we move a numeric or aplanumeric or alphabetic variables to a comp, comp-1 or comp-2 variables?
If it so what happened to the pic clause of the sending and receving variable?
Also can you pls provide me some examples for the various possible conditions of move statements?
Thanks in advance |
|
Back to top |
|
|
priya
Moderator
Joined: 24 Jul 2003 Posts: 568 Location: Bangalore
|
|
|
|
You can move numeric to comp
But alphanumeric & alphabetic is not possible
Allowed Move
N / NE to AN / ANE
AN / ANE to A
and wise versa, except ANE to NE
Note: N - Numeric
NE - Numeric Edited
AN - Alphanumeric
ANE - AN Edited
A - alphanumeric |
|
Back to top |
|
|
DIVAKAR
New User
Joined: 26 Jun 2004 Posts: 3 Location: Trichy
|
|
|
|
hi pandian
we can move numeric value to comp,comp1 comp2 fileds
suppose
77 I pic 9999.
77 J PIC S9(4) COMP.
MOVE I TO J.
DATA :
I - 1234
J - 234
comp1
-------
77 I pic 9999.
77 J COMP1.
MOVE I TO J.
DATA :
I - 1234
J - .12340000E+4
comp2
-------
77 I pic 9999.
77 J COMP1.
MOVE I TO J.
DATA :
I - 1234
J - .1234000000000000E+4
Dhivakar - Trichy |
|
Back to top |
|
|
shammiullah
New User
Joined: 13 Jun 2005 Posts: 24
|
|
|
|
77 I pic 9999.
77 J PIC S9(4) COMP.
MOVE I TO J.
DATA :
I - 1234
J - 234
................here is it for sure that if i display j it'll show 234.comp will internally take 2 bytes for j.so,where the sign will b stored. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Sham,
J will contain 04D2, which is the binary equivilant of 1234. The sign is 0 (pos) in the hi ord bit of the hi ord byte.
If -1234 were moved to J, it would contain FB2E. The sign is 1 (neg) in the hi ord bit of the hi ord byte. |
|
Back to top |
|
|
mbr_raja
New User
Joined: 15 Nov 2004 Posts: 26 Location: Chennai, India
|
|
|
|
You can move numeric or alphanumeric to comp, comp-1 etc, but the difference is as follows:
Move numberic to comp or comp-1 working fine
Move alphanumeric to comp or comp-1 SOC4 error
Since Comp and Comp-1 tries to stores the data in Hex format in the memory, but you cannot process or dispaly, If you try this, i leads SOC4 error.
01 c pic 99 comp.
Ex: move 123 to c
move "ABCD" to C |
|
Back to top |
|
|
shammiullah
New User
Joined: 13 Jun 2005 Posts: 24
|
|
|
|
hI MMWIFE,
WAT U'VE SAID IS RIGHT.....PREVIOUSLY SOME ONE HAS WRITTEN THAT I & J WILL CONTAIN 1234 AND 234.
BUT AS U'VE SAID IT'LL B LIKE
I-----1234
J-----123D IF ITZ DELARED AS S9(4)COMP.
IT'LL BE
I------1234
J------1234 IF ITZ DELARED AS 9(4)COMP.
CORRECT ME IF I'M WRONG...........THANK U. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
I'm assuming both I and J are signed. If you add another field - K with a
PIC S9(4) USAGE DISPLAY and move J to K, then:
The contents of K will be 123D if the 1234 is positive.
The contents of K will be 123M if the 1234 is negative.
If K is defined as PIC 9(4) USAGE DISPLAY, then K will contain
1234 in both cases. |
|
Back to top |
|
|
|