View previous topic :: View next topic
|
Author |
Message |
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Hi Experts,
I am having some confusion about the way the COMP-3 variables are initialized.
For example the variables are defined in below manner
01 WK-Rahul-1
05 WK-Rahul-11 PIC S9(13)V99.
05 WK-Rahul-12 PIC S9(13)V99.
05 WK-Rahul-13 PIC S9(13)V99.
05 WK-Rahul-14 PIC +9(13)V99.
05 WK-Rahul-15 PIC +9(13)V99.
05 WK-Rahul-16 PIC +9(13)V99.
05 WK-Rahul-17 PIC S9(13)V99 COMP-3.
05 WK-Rahul-18 PIC S9(13)V99 COMP-3.
Someone told me that when we initialize the WK-Rahul-1 like
MOVE ZERO TO WK-Rahul-1. It will initailize WK-Rahul-17 and WK-Rahul-18 with low values instead of zero.
Is this right?
Thanks. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
rgupta71 wrote: |
Hi Experts,
I am having some confusion about the way the COMP-3 variables are initialized.
For example the variables are defined in below manner
01 WK-Rahul-1
05 WK-Rahul-11 PIC S9(13)V99.
05 WK-Rahul-12 PIC S9(13)V99.
05 WK-Rahul-13 PIC S9(13)V99.
05 WK-Rahul-14 PIC +9(13)V99.
05 WK-Rahul-15 PIC +9(13)V99.
05 WK-Rahul-16 PIC +9(13)V99.
05 WK-Rahul-17 PIC S9(13)V99 COMP-3.
05 WK-Rahul-18 PIC S9(13)V99 COMP-3.
Someone told me that when we initialize the WK-Rahul-1 like
MOVE ZERO TO WK-Rahul-1. It will initailize WK-Rahul-17 and WK-Rahul-18 with low values instead of zero.
Is this right?
Thanks. |
Firstly, it is good to format your example, but pointless then to not use the Code button (highlight the text where you want formatting preserved) to keep it all in line. Then use Preview before the final post to check the alignment is what you want.
"Someone" was wrong.
If you move ZERO (or variants thereof, ZEROS, ZEROES) to a group item, you will get Zoned Decimal zeros in every byte of the group item. You will get F0F0F0F0... in every position of every field. If you then try to add to 17 or 18, S0C7. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Someone told me that when we initialize the WK-Rahul-1 like |
We must be quite careful of who we listen to and believe. . .
There is much mis-information around - both from people and the internet.
Putting the code into a test program and looking at the result is most helpful when one is confused |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
when all else fails,
RTFM:
start with MOVE.
then graduate to the INITIALIZE statement.
There are links to manuals at the top of every page of this forum. |
|
Back to top |
|
|
nigelosberry
New User
Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
rgupta71 wrote: |
Someone told me that when we initialize the WK-Rahul-1 like
MOVE ZERO TO WK-Rahul-1. It will initailize WK-Rahul-17 and WK-Rahul-18 with low values instead of zero.
Is this right?
Thanks. |
What is stopping you from doing research by yourself.
Add a display after
Code: |
MOVE ZERO TO WK-Rahul-1 |
go to spool and do a "set hex on" and see what's the content of your 01 level variable.
To understand the content go through the online tutorials about the 3 numeric types namely: Packed Decimal, Zoned Decimal and Binary. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Why include binary and exclude floating-point?
If the 01 is displayed, not much point in setting hex on.
Code: |
DISPLAY ">" WK-Rahul-1 "<" |
Nothing interesting to look for, all X'F0'.
I suppose from the display you could intuit that none of the subordinate fields conform to picture. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
The most important reply here is from nigelosberry, a new user, who is telling you to JUST TRY IT AND SEE WHAT YOU GET, although he didn't yell it.
Do you want the answer to just this question, or do you want to be able to find answers?
Also, your code is bad, because
needs a period at the end.
Asking folks to review code you have not even compiled or run is not cool. |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
I coded the program and checked the output. It is giving x'F0' s display.
Thank You all for your reply. |
|
Back to top |
|
|
|