[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: gnubol: STD - What do you think *should* happen
Hello Bill,
first I testet the coding on "IBM COBOL for MVS & VM 1.2.2" and I send you
the result.
<<CobolTestAlphaEdit.txt>>
And second the answer on your question, what do I think, what SHOULD happen.
My oppinion is, that a picture-clause should not influence the real value of
a data. (I know, that is not congruent with the way, the cobol-move works
now, but you asked for what we think.) For example, when you format a
numeric data item in Excel, you can assign a "picture-clause" independently
from the internally stored valus. That's the way, I would prefere for the
cobol-move too.
An example from Excel:
Value Picture 1 Picture 2
10000 10000,00 10.000
The consequence of this behavier I show on the source:
---------------------------------------------------------------------------
01 group1.
05 alpha-edit1 pic x/xx. // should only be 3 physical bytes
01 group2.
05 alpha-edit2 pic xx/x. // should only be 3 physical bytes
01 elem3x pic xxx.
...
move "ABC" to group1
move alpha-edit1 to group2
move alpha-edit2 to elem3x
display alpha-edit1 // "A/BC"
display alpha-edit2 // "AB/C"
display elem3x // "ABC"
-------------------------------------------------------------
The edit-step should be decoupled from the move.
The compiler should handle the edit-description form the picture-clause like
it handles the virtual comma.
So, any move from any group or elementary item move 3 physical bytes.
So there is no loss of data.
For my example above, the COBOL for MVS & VM gives the following result:
*******************
ALPHA-EDIT1 = ABC
ALPHA-EDIT2 = ABC
ELEM3X = ABC
*******************
So far my opinion,
many regards
Carsten
> -----Ursprüngliche Nachricht-----
> Von: William M. Klein [SMTP:wmklein@ix.netcom.com]
> Gesendet am: Samstag, 29. Januar 2000 17:04
> An: gnu
> Betreff: gnubol: STD - What do you think *should* happen
>
> During the recent J4 meeting, I accepted an assignment to write a paper to
> "fix" some of the wording on what exactly the PICTURE clause symbols
> really
> do (mean?). I plan on creating a test-case that various people can run
> with
> the ('74 or '85) compiler of your choice, but my question is what do you
> think SHOULD happen (today - not with a future Standard) with the
> following
> type of source code:
>
> 01 GROUP1.
> 05 ALPHA-EDIT PIC X/X.
> 01 ELEM1 PIC XX.
> ...
> MOVE "ABC" TO GROUP1
> MOVE ALPHA-EDIT TO ELEM1
>
>
> ****
>
> The question is what the 2nd move "should" do. I can think of (at least)
> 3
> possibilities:
>
> 1) The data "AB" stored in the first two bytes of ALPHA-EDIT will be moved
> to
> ELEM1
>
> 2) The data "A" stored in the first byte of ALPHA-EDIT will be move to the
> first byte of ELEM1 - and the character "/" (which is what the picture
> SAYS
> is in the 2nd byte) will be moved to the 2nd byte of ELEM1
>
> 3) The program will ABEND or have other "unpredictable" results because
> the
> data in ELEM1 does not "match" what the PICTURE clause says *should* be in
> that 2nd byte.
>
> ***
>
> OK, folks - what do you think should happen? (Any comments on what
> various
> compilers do - both when running in their "ANSI-conforming" modes and in
> any
> "full optimization" mode - will be gratefully accepted.)
>
> --
> Bill Klein
> wmklein <at> ix dot netcom dot com
>
>
>
> --
> This message was sent through the gnu-cobol mailing list. To remove
> yourself
> from this mailing list, send a message to majordomo@lusars.net with the
> words "unsubscribe gnu-cobol" in the message body. For more information
> on
> the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.
****** ***************************** Top of Data **********
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. ALPHEDIT.
000003 DATA DIVISION.
000004 WORKING-STORAGE SECTION.
000005 01 GROUP1.
000006 05 ALPHA-EDIT PIC X/X.
000007 01 ELEM1 PIC XX.
000008
000009 PROCEDURE DIVISION.
000010 MOVE "ABC" TO GROUP1
000011 MOVE ALPHA-EDIT TO ELEM1
000012 DISPLAY "1, ALPHA-EDIT = " ALPHA-EDIT
000013 DISPLAY "1, ELEM1 " ELEM1
000014
000015 MOVE "ABC" TO ALPHA-EDIT
000016 MOVE ALPHA-EDIT TO ELEM1
000017 DISPLAY "2, ALPHA-EDIT = " ALPHA-EDIT
000018 DISPLAY "2, ELEM1 " ELEM1
000019
000020 GOBACK
000021 .
000022
****** **************************** Bottom of Data ********
Result (for CMPR2 and NOCMPR2):
***********************
1, ALPHA-EDIT = ABC
1, ELEM1 AB
2, ALPHA-EDIT = A/B
2, ELEM1 A/
***********************