Menu ▾ ▴

#417 VALUE clause for TABLE entries

GC 3.x
pending
None
5 - default
2024-03-10
2022-06-21
No

The 2002 COBOL standard established the possibility of using the VALUE clause to assign values to table elements. Even individually and even on multi-dimensional tables.
See in the attached screenshots the FORMAT 2 of the VALUE clause and the examples of how to initialize the elements of tables.

3 Attachments

Related

Wish List: #417

Discussion

  • Simon Sobisch

    Simon Sobisch - 2022-06-21

    This was added to GnuCOBOL some weeks ago, while it isn't finished yet you may want to check the nightly builds.

     
  • Eugenio Di Lorenzo

    Thanks Simon, very very good !
    I don't know how to use the nightly build.
    Perhaps now an updated version would be useful that we can download from Arnold's site.

     
  • Simon Sobisch

    Simon Sobisch - 2022-12-03

    Current implementation is expected to be "quite stable" and won't go away.
    The parsing is fully done for several formats, the FROM and TO options don't land correctly in the codegen and are therefore PENDING - patches welcome -.

     
  • Simon Sobisch

    Simon Sobisch - 2022-12-03

    Again, the most important part seems to be documentation - @dilodilo maybe you can checkout what is working and create the notes to add to the PG?

     
    • Eugenio Di Lorenzo

      ok I can try asap, but ... the question is the following : can I use the latest release that I'm going to download from the Arnold site to test these new features?

      Is this one the correct compiler release to use for ?

      (NEW) GnuCOBOL 3.2 BDB Preview (23Oct2022) GC32-BDB-Preview-rename-7z-to-exe.7z --
      MinGW GnuCOBOL compiler for Windows XP/7/8/10. Includes GCC 9.2.0, Berkeley DataBase 18.1.40 for Indexed Sequential file access support, GMP 6.2.1, and PDCursesMod 4.3.4 (25.6 megabytes). Rename .7z to .exe for self-extracting archive.

       
      • Simon Sobisch

        Simon Sobisch - 2022-12-04

        That part was a bit buggy in the preview, I'd suggest to use the nightly binaries für testing instead.

         
  • Simon Sobisch

    Simon Sobisch - 2023-03-22

    @dilodilo: could you please recheck the state and suggest additions to the PG?

     
    • Eugenio Di Lorenzo

      I did a small test but unfortunately it doesn't seem to work yet.
      see screenshot

             >>SOURCE FREE
      IDENTIFICATION DIVISION.
      PROGRAM-ID. TESTVALUETAB.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 VARTAB1.
         05 EL-TAB PIC 9 OCCURS 3 VALUE 1 2.
      PROCEDURE DIVISION.
          display VARTAB1 at 0210
          accept omitted
          STOP RUN.
      

      using this from Arnold site:

      cobc (GnuCOBOL) 3.2-rc2.0
      Copyright (C) 2023 Free Software Foundation, Inc.
      License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
      This is free software; see the source for copying conditions.  There is NO
      warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
      Built     Feb 11 2023 00:45:32
      Packaged  Feb 11 2023 01:47:30 UTC
      C version (MinGW) "12.2.0"
      
       
      • Simon Sobisch

        Simon Sobisch - 2023-03-22

        Can you please try with VALUES instead of VALUE and - if you still see an error with specifying 3 values?

         
        • Eugenio Di Lorenzo

          Hi, using the VALUES clause instead of VALUE, the program compiles without errors (!?!?!) . but VALUE and VALUES should work the same way.
          However, the execution does not provide the expected result.
          Table fields are not initialized as they should according to the VALUES clause.
          The following program demonstrates the above.

                 >>SOURCE FREE
          IDENTIFICATION DIVISION.
          PROGRAM-ID. TESTVALUETAB.
          DATA DIVISION.
          WORKING-STORAGE SECTION.
          01 VALTAB1.
             05 EL-TAB1 PIC 99 OCCURS 3 VALUES ARE 1 2 3 .
          01 VALTAB2.
             05 EL-TAB2 PIC 99 OCCURS 3 VALUES ARE 1 2 3 FROM(1) TO (3) .
          01 VALTAB3.
             05 EL-TAB3 PIC XX OCCURS 4 VALUES     "AA" "BB" "CC" "DD"  .
          
          PROCEDURE DIVISION.
              *> initialize VALTAB1 all to value
              display"VALTAB1=" at 0201 display VALTAB1 at 0210
              accept omitted
          
              move 9 to EL-TAB1(2)
              display"VALTAB1=" at 0301 display VALTAB1 at 0310
              accept omitted
          
              initialize VALTAB2 all to value
              display"VALTAB2=" at 0401 display VALTAB2 at 0410
              accept omitted    
          
              initialize VALTAB3 all to value
              display"VALTAB3=" at 0501 display VALTAB3 at 0510
              accept omitted       
              STOP RUN.
          

          The program display as attached screenshot::

           

          Last edit: Eugenio Di Lorenzo 2023-03-22
      • Vincent (Bryan) Coen

        Does it work if you change the value clause to :   VALUE 1 2 3.  ?

        On 22/03/2023 12:54, Eugenio Di Lorenzo wrote:

        I did a small test but unfortunately it doesn't seem to work yet.
        see screenshot

        |>>SOURCE FREE IDENTIFICATION DIVISION. PROGRAM-ID. TESTVALUETAB. DATA
        DIVISION. WORKING-STORAGE SECTION. 01 VARTAB1. 05 EL-TAB PIC 9 OCCURS
        3 VALUE 1 2. PROCEDURE DIVISION. display VARTAB1 at 0210 accept
        omitted STOP RUN. |

        using this from Arnold site:

        Attachments:


        [feature-requests:#417]
        https://sourceforge.net/p/gnucobol/feature-requests/417/ VALUE
        clause for TABLE entries

        Status: open
        Group: unclassified
        Created: Tue Jun 21, 2022 06:13 PM UTC by Eugenio Di Lorenzo
        Last Updated: Wed Mar 22, 2023 07:34 AM UTC
        Owner: nobody
        Attachments:

        The 2002 COBOL standard established the possibility of using the VALUE
        clause to assign values to table elements. Even individually and even
        on multi-dimensional tables.
        See in the attached screenshots the FORMAT 2 of the VALUE clause and
        the examples of how to initialize the elements of tables.


         

        Related

        Wish List: #417


        Last edit: Vincent (Bryan) Coen 2024-03-09
        • Eugenio Di Lorenzo

          The error doesn't change even if I assign three values instead of two.

           
        • Eugenio Di Lorenzo

          this gives following compilation error
          ** "syntax error, unexpected ."**

           
    • Eugenio Di Lorenzo

      Even if the tests have not yet been successful, I have nevertheless prepared this documentation. It should be added to the Programmer's Guide at chapter
      6.9.53. VALUE
      A new format should be added that we can call
      VALUE (for tables) Syntax
      The syntax to add is as follows:

      {VALUE IS  } {{literal-1}... FROM({subscript-1}...) [TO({subscript-2}...)]}...
      {~~~~~     }                 ~~~~                    ~~
      {VALUES ARE}
      {~~~~~~    } 
      
       
  • Vincent (Bryan) Coen

    I cannot add any vaporware and that includes vaporfeatures.

    Let me know when it works for v3.2 and I will add it.

     
  • Simon Sobisch

    Simon Sobisch - 2023-03-26

    Please see https://sourceforge.net/p/gnucobol/code/HEAD/tree/tags/gnucobol-3.2-rc2/tests/testsuite.src/run_initialize.at#l655 for what is implemented.

    VALUE and VALUES should work the same way.

    If you can find a resolution to support that in the parser - patches welcome.

    Note: standard COBOL allows multiple values only with the FROM clause - in this case the parser can differentiate that; otherwise it can't and therefore don't expect multiple values if you just specify VALUE a b.

     
  • Vincent (Bryan) Coen

    Today I have added this to the Programmer Guide.
    So this can be closed After successful testing by ???

     
  • Vincent (Bryan) Coen

    • status: open --> pending
    • assigned_to: Vincent (Bryan) Coen
    • Group: unclassified --> GC 3.x
     

Log in to post a comment.