Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Cobol > Re: MOVE COMP-3...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 10 Topic 4043 of 4280
Post > Topic >>

Re: MOVE COMP-3 TO DISPLAY.

by pottmi <pottmi@[EMAIL PROTECTED] > Mar 5, 2008 at 06:17 PM

Pete,

Your suggestion worked.  thanks.  I did not know about using a period
in the picture clause, that was the trick that makes the redefines
graceful.

For the benefit of others, here is a cut and paste ready scrap of
code:
       01  CONSTANTS.
           02 ACOMP3 PIC 9(4)v9 COMP-3.
           02 ADISPLAY PIC X(6).
           02 ANUMERIC PIC Z(4).9.
           02 ASTRING REDEFINES ANUMERIC PIC X(6).
      *
       PROCEDURE DIVISION.
       FIRST-PARA.
           MOVE 1234.5 TO ACOMP3.
      *     MOVE ACOMP3 TO ADISPLAY.
      *     DISPLAY ADISPLAY.

           MOVE ACOMP3 TO ANUMERIC.
           DISPLAY "ASTRING = " ASTRING.

           STOP RUN.

The commented out MOVE statement produces this error on the latest
version of microfocus compiler:

pottmi@[EMAIL PROTECTED]
> cob moverule.cbl
    20     MOVE ACOMP3 TO ADISPLAY.
*1029-
E***************************
**
**    A non-integer is being moved to an alphanumeric data item

Given that, can you clarify your statement that the MOVE is legal?

--
Michael Potter


On Mar 5, 6:48 pm, "Pete Dashwood"
<dashw...@[EMAIL PROTECTED]
> wrote:
> "pottmi" <pot...@[EMAIL PROTECTED]
> wrote in message
>
>
news:3417ff0f-baad-4cb9-9b24-f23079af4c18@[EMAIL PROTECTED]
>
> > COBOL Crew,
>
> > This code is broken because the non-integer move to alphanumeric is
> > illegal.
>
> No it isn't. The code is not broken and the move is not illegal. You can
> move non-integer to Alphanumeric with no problem.
>
> Your understanding may be "broken" :-)
>
> It currently shows 12345b   ...where "b" is a blank, right?
>
> > --------------------
> > 01 ACOMP3 PIC 9999v9 COMP-3.
> > 01 ADISPLAY PIC X(6).
>
> > MOVE 1234.5 to ACOMP3.
> > MOVE ACOMP3 TO ADISPLAY.
> > DISPLAY ADISPLAY.
> > -------------------
>
> > What are some options for me to change this code such that the output
> > of the "DISPLAY ADISPLAY" statement is "1234.5" with the constraint
> > that ACOMP3 and ADISPLAY must remain defined as they are?
>
> That seems to be a very unlikely thing to actually want to do (You could
> simply move "1234.5" to ADISPLAY and display it to achieve what you
stated
> above...), so I have assumed that what you really want is a single
decimal
> place, preceded by a point, capable of handling various values:
>
>  01 ACOMP3 PIC 9999v9 COMP-3.
>  01 ADISPLAY PIC X(6).
>
> ... add two lines...
>  01 ADISPLAY-EDITED PIC z(4).9.
>  01 ADSTRING REDEFINES ADISPLAY-EDITED PIC X(6).
> ...
>  MOVE 1234.5 to ACOMP3.
> MOVE ACOMP3 TO ADISPLAY-EDITED.
> MOVE ADSTRING TO ADISPLAY.
> DISPLAY ADISPLAY.
>
> This will do what you require, within the constraints you specified.
>
> REDEFINES is one of the most powerful features in COBOL.
>
> Pete.
> --
> "I used to write COBOL...now I can do anything."
 




 10 Posts in Topic:
MOVE COMP-3 TO DISPLAY.
pottmi <pottmi@[EMAIL   2008-03-05 16:00:26 
Re: MOVE COMP-3 TO DISPLAY.
"Pete Dashwood"  2008-03-06 13:48:48 
Re: MOVE COMP-3 TO DISPLAY.
spambait@[EMAIL PROTECTED  2008-03-06 02:36:56 
Re: MOVE COMP-3 TO DISPLAY.
docdwarf@[EMAIL PROTECTED  2008-03-06 01:26:24 
Re: MOVE COMP-3 TO DISPLAY.
pottmi <pottmi@[EMAIL   2008-03-05 18:17:18 
Re: MOVE COMP-3 TO DISPLAY.
Arnold Trembley <arnol  2008-03-06 04:14:58 
Re: MOVE COMP-3 TO DISPLAY.
"Pete Dashwood"  2008-03-07 10:19:02 
Re: MOVE COMP-3 TO DISPLAY.
"Rick Smith" &l  2008-03-06 19:34:38 
Re: MOVE COMP-3 TO DISPLAY.
"Pete Dashwood"  2008-03-07 14:48:53 
Re: MOVE COMP-3 TO DISPLAY.
Howard Brazee <howard@  2008-03-06 07:58:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 21:15:45 CDT 2008.