I have to ask :-)
Why use this syntax ?
Consider an array with 100 variables.
I don't think that even Source Free (that subverted COBOL) could manage such an array with this obtuse "C" like syntax.
Strange to me :-)
Last edit: Ralph Linkletter 2025-06-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I believe that COBOL syntax is the easiest to read among all programming languages.
Even in this case listing the individual 7 values is the simplest and most natural thing you can have "VALUES ARE x y z etc ".
Assigning 7 values is therefore very simple.
Even if the values were many more, IMHO it remains the most readable solution.
Much easier to use than the usual "REDEFINES".
And I add that you could also write FROM ... TO as follows, even clearer and simpler, perhaps a bit verbose.
WORKING-STORAGE SECTION.
01 wTAB-FREQ.
05 wRAPP-FREQ occurs 7 PIC 9999V9999 VALUES ARE 1 1.125 1.25 1.333 1.5 1.6667 1.875 FROM (1) TO (7).
Also in my opinion there is no reason to continue writing COBOL source code with "SOURCE FIXED" when the compiler supports "SOURCE FREE".
All languages now allow you to freely write the line of code without column restrictions,
and with video screens, much larger than the old 3270, which allow you to read long lines of source code well.
If I'm not mistaken, only IBM COBOL on mainframes does not allow SOURCE FREE.
Last edit: Eugenio Di Lorenzo 2025-06-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is another sample program that demonstrates that the "VALUES ARE" clause works in some cases and does not work in some cases.
>>SOURCEFREEIDENTIFICATIONDIVISION.PROGRAM-ID.TESTVALUE7.DATADIVISION.WORKING-STORAGESECTION.01WS.05IX1PIC99.05IX2PIC99.05IX3PIC99.05MONTH-IN-YEAROCCURS13TIMESPICX(3)VALUES"jan""feb""mar""apr""may""jun""jul""aug""sep""oct""nov""dec""Hi".05DAYS-IN-MONTHOCCURS13TIMESPIC9(2)BINARYVALUES312831303130313130313031.05DAYS-MONTHSOCCURS2TIMES.06DAYX-MONTHXOCCURS4TIMES.07DAY-MONTHOCCURS3TIMES.10XXX1PICXVALUE" ".10MONTHSPICX(3)VALUES"Jan""Feb""Mar""Apr""May""Jun""Jul""Aug""Sep""Oct""Nov""Dec""JAN""FEB""MAR""APR""MAY""JUN""JUL""AUG""SEP""OCT""NOV""DEC".*>"Bye".10SEPXPICXXVALUE", ".10DAYSPIC99VALUES312831303130313130313031912891909190919190919091.10PERPICXVALUE".".07FLRPICX(4)VALUES" <A>"" <B>"" <C>"" <D>"" <E>"" <F>"" <G>"" <H>".*>" <*>".PROCEDUREDIVISION.DISPLAY"Simple OCCURS with multi VALUES".PERFORMVARYINGIX1FROM1BY1UNTILIX1>13DISPLAYIX1": "MONTH-IN-YEAR(IX1)" has "DAYS-IN-MONTH(IX1)" days"END-PERFORMacceptomitteddisplayspaceDISPLAY"Complex OCCURS with multi VALUES".PERFORMVARYINGIX3FROM1BY1UNTILIX3>2PERFORMVARYINGIX2FROM1BY1UNTILIX2>4DISPLAYIX3"-"IX2": "DAYX-MONTHX(IX3,IX2)END-PERFORMdisplayspaceEND-PERFORMSTOPRUN.
Last edit: Eugenio Di Lorenzo 2025-06-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am surprised. In the past (before retirement), the ONLY place I ever saw or used "VALUES ARE" was in 88 level condition-names. I never imaged this alternate use was allowed or even possible.
The test program does suggest a bug in GnuCOBOL, but in some cases it works amazingly well. I compiled with a MinGW 32-bit GnuCOBOL 3.2 compiler.
It seems like "VALUES ARE" did not work as expected for "PIC 99", but worked correctly for "PIC 9(02)". If PIC 9(02) works, I think PIC 99 should work equally as well, by the rule of least astonishment.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm only aware of BS2000 (mainframe from Fujitsu) where this is implemented since decades.
Standard COBOL got that feature (format 3 "table-format") with 2002, I think as soon as customers request that specific feature, it will be in Enterprise COBOL as well (because it is useful and non-conflicting).
Oh, and just a note - someone posted about VALUES x THRU y, but that's really only part of condition-format of VALUE clause (the one edited his/her post, so that info is not here any more, but I still wanted to note that for people reading with a topic-subscription).
Note: I don't think we need a support-option to disable this, but we could alias VALUES to VALUE - because (other than the standard) only with the plural form this "new" (24 year old) feature is active.
... and, we still need a qualified bug report "this works" but "this doesn't", a pre-analysis of the reason is welcomed, but not mandatory :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the following program
VALUES ARE
clause seems does not work.Am I the one doing something wrong ?
Does not work with v3.2 final so suggest you create a bug report.
I have to ask :-)
Why use this syntax ?
Consider an array with 100 variables.
I don't think that even Source Free (that subverted COBOL) could manage such an array with this obtuse "C" like syntax.
Strange to me :-)
Last edit: Ralph Linkletter 2025-06-01
I believe that COBOL syntax is the easiest to read among all programming languages.
Even in this case listing the individual 7 values is the simplest and most natural thing you can have "
VALUES ARE x y z
etc ".Assigning 7 values is therefore very simple.
Even if the values were many more, IMHO it remains the most readable solution.
Much easier to use than the usual "
REDEFINES
".And I add that you could also write FROM ... TO as follows, even clearer and simpler, perhaps a bit verbose.
Also in my opinion there is no reason to continue writing COBOL source code with "SOURCE FIXED" when the compiler supports "SOURCE FREE".
All languages now allow you to freely write the line of code without column restrictions,
and with video screens, much larger than the old 3270, which allow you to read long lines of source code well.
If I'm not mistaken, only IBM COBOL on mainframes does not allow SOURCE FREE.
Last edit: Eugenio Di Lorenzo 2025-06-01
I agree that COBOL is the easiest language to read.
I do not agree with your position on VALUES are.
95 + percent of COBOL is written in IBM COBOL.
To each his own - heh :-)
Here is another sample program that demonstrates that the "
VALUES ARE
" clause works in some cases and does not work in some cases.Last edit: Eugenio Di Lorenzo 2025-06-01
I am surprised. In the past (before retirement), the ONLY place I ever saw or used "VALUES ARE" was in 88 level condition-names. I never imaged this alternate use was allowed or even possible.
The test program does suggest a bug in GnuCOBOL, but in some cases it works amazingly well. I compiled with a MinGW 32-bit GnuCOBOL 3.2 compiler.
It seems like "VALUES ARE" did not work as expected for "PIC 99", but worked correctly for "PIC 9(02)". If PIC 9(02) works, I think PIC 99 should work equally as well, by the rule of least astonishment.
Neither program will compile on the mainframe.
I'm only aware of BS2000 (mainframe from Fujitsu) where this is implemented since decades.
Standard COBOL got that feature (format 3 "table-format") with 2002, I think as soon as customers request that specific feature, it will be in Enterprise COBOL as well (because it is useful and non-conflicting).
Oh, and just a note - someone posted about
VALUES x THRU y
, but that's really only part of condition-format of VALUE clause (the one edited his/her post, so that info is not here any more, but I still wanted to note that for people reading with a topic-subscription).Note: I don't think we need a support-option to disable this, but we could alias VALUES to VALUE - because (other than the standard) only with the plural form this "new" (24 year old) feature is active.
... and, we still need a qualified bug report "this works" but "this doesn't", a pre-analysis of the reason is welcomed, but not mandatory :-)
I have created a bug report for this:
https://sourceforge.net/p/gnucobol/bugs/1119/