Table Sort

Anonymous
2014-02-21
2014-02-25
  • Anonymous - 2014-02-21

    Hello,

    when defining a table like this:

        01 Table.
            02 NumberOfLines   pic 9(9) comp-5 value 10.
            02 TabLine         occurs 1 to 100 depending NumberOfLines.
                04 SortItem    pic x(10).
    

    the command : "Sort TabLine ascending SortItem" seems to fail.

    A definition like this will work:

        01 NumberOfLines      pic 9(9) comp-5 value 10.
        01 Table.
            02 TabLine         occurs 1 to 100 depending NumberOfLines.
                04 SortItem    pic x(10).
    

    Feature or bug?

    Regards
    Ulli

     
    Last edit: Simon Sobisch 2014-02-25
  • Simon Sobisch

    Simon Sobisch - 2014-02-22

    Hi Ulli,

    I think this should work. What do you mean with "seems to fail"? It would be a good idea to post a full sample program (with both definitions in) and posting the results.
    Please add output from cobc --version, too.

    Simon

     
    • Anonymous - 2014-02-24

      Hi Simon.

      here is an example:

             IDENTIFICATION DIVISION.
             PROGRAM-ID. TestSort.
             ENVIRONMENT DIVISION.
             DATA DIVISION.
             WORKING-STORAGE SECTION.
             01 k             pic 9(9) comp-5.
      
             01 Anz1          pic 9(9) comp-5 value 4.
             01 tab1.
                05 zeile1 OCCURS 1 to 4 depending Anz1 
                                       descending tab1-nr.
                   10 tab1-nr pic 99.
      
             01 tab2.
                05 Anz2          pic 9(9) comp-5 value 4.
                05 zeile2 OCCURS 1 to 4 depending Anz2 
                                       descending tab2-nr.
                   10 tab2-nr pic 99.
      
             procedure division.
             a.
                 perform varying k from 1 by 1 until k > 4
                   move k to tab1-nr(k), tab2-nr(k)
                 end-perform
      
                 sort zeile1 descending tab1-nr
                 sort zeile2 descending tab2-nr
      
                 perform varying k from 1 by 1 until k > 4
                   display  tab1-nr(k)
                 end-perform
      
                 perform varying k from 1 by 1 until k > 4
                   display  tab2-nr(k)
                 end-perform
      
                 stop run.
      

      which gives the output:

      04
      03
      02
      01
      01
      02
      03
      04
      

      and the second SORT doesn't work ;-(

      My Cobc-Version :

      d:\vb\_cobol\DVBrief_oc>cobc -V
      cobc (OpenCOBOL) 2.0.0
      Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida
      Copyright (C) 2006-2012 Roger While
      This is free software; see the source for copying conditions.  There is NO
      warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      Built     Oct 15 2013 16:06:14
      Packaged  Feb 11 2012 12:36:31 UTC
      C version "4.8.1"
      

      Ulli

       
      Last edit: Simon Sobisch 2014-02-25
  • Simon Sobisch

    Simon Sobisch - 2014-02-25

    Thank you for reporting this.
    Seems like a bug, created [#68].

    Simon

     

    Related

    Bugs: #68


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks