HP3000-L Archives

December 2003, Week 2

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:
Walter Murray <[log in to unmask]>
Reply To:
Walter Murray <[log in to unmask]>
Date:
Fri, 12 Dec 2003 17:03:52 -0600
Content-Type:
text/plain
Parts/Attachments:
text/plain (34 lines)
 "Brian Donaldson" <[log in to unmask]> wrote:
>
> Moving "X" type fields straight into COMP fields doesn't work !
>

Actually, it's perfectly legal in COBOL to move an alphanumeric data item to
a numeric data item with COMP format.  The necessary conversion from DISPLAY
format to COMP format takes place.  Data is moved as if the sending operand
were described as an unsigned numeric integer.  If the content of the
sending operand is not an unsigned numeric integer, the result is undefined.

So, for example, the following is legal COBOL.  It displays "12,345,678".

 IDENTIFICATION DIVISION.
 PROGRAM-ID. COBTEST.
 DATA DIVISION.
 WORKING-STORAGE SECTION.
 01  A    PIC X(8).
 01  B    PIC S9(8)    COMP.
 01  C    PIC ZZZ,ZZZ,ZZ9.
 PROCEDURE DIVISION.
 BEGIN.
     MOVE "12345678" TO A
     MOVE A TO B
     MOVE B TO C
     DISPLAY C
     STOP RUN.
 END PROGRAM COBTEST.

Walter

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

ATOM RSS1 RSS2