HP3000-L Archives

May 2005, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Dave Powell, MMfab" <[log in to unmask]>
Reply To:
Dave Powell, MMfab
Date:
Thu, 5 May 2005 11:03:47 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (87 lines)
If you want to stick to 'redefines', and you can get the original character
value into right-justified format, then try:

01 WS-A           PIC X(04)  just right.
01 WS-B redefines WS-A   pic z(04).
01 WS-C           pic 9(04).

MOVE 3 TO WS-A.
MOVE WS-B TO WS-C.

DISPLAY " A:" WS-A ":"
DISPLAY " B:" WS-B ":"
DISPLAY " C:" WS-C ":"

Which gives me
A:   3:
B:   3:
C:0003:
Which might (?) be what you want ?

If you prefer to use compute & numval, it might  be safer to always use
'rounded' even if rounding does not look necessary.  Maybe there was a patch
sometime and I 'missed the memo', but long ago I saw numval w/o rounding
produce a clearly wrong answer, and rounding fixed it.  I forget the exact
number but it was something like
'    123.45' yielding 123.46, while every other data we fed it worked ok.

Dave Powell,   MMfab

----- Original Message -----
From: "Rao, Raghu" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Thursday, May 05, 2005 09:05
Subject: [HP3000-L] COBOL : Redefines question


Hi,

In cobol, is there any way that I get the redefined value from character
value into a proper numeric value ?

For Ex:
*************
01 WS-A           PIC X(04).
01 WS-B redefines WS-A   pic 9(04).
02 WS-C           pic 9(04).
...
MOVE 3 TO WS-A.
MOVE WS-B TO WS-C.
..
DISPLAY " A:" WS-A ":"
DISPLAY " B:" WS-B ":"
DISPLAY " C:" WS-C ":"

Results are
A:3   :
B:3   :
C:3000:


I want the results to be:
--------------------------------
A:3   :
B:0003:
C:3:

Thanks.
Raghu Rao


Confidentiality Notice:
The information contained in this electronic message is intended for the
exclusive use of the individual or entity named above and may contain
privileged or confidential information.
If the reader of this message is not the intended recipient or the employee or
agent responsible to deliver it to the intended recipient, you are hereby
notified that dissemination, distribution or copying of this information is
prohibited.
If you have received this communication in error, please notify the sender
immediately by telephone and destroy the copies you received.

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2