HOME  NEWS  FORUM  DOWNLOAD  LINK
OpenCOBOL - an open-source COBOL compiler
Main Menu
Download
Documentation
Development
Who's Online
20 user(s) are online (6 user(s) are browsing Forum)

Members: 1
Guests: 19

tillywor, more...
Powered by
SourceForge

Xoops

Creative Commons

OpenCOBOL Forum Index
   OpenCOBOL
     implementation of ocsort
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
Angus
Posted on: 2010/2/15 22:21
Not too shy to talk
Joined: 2009/12/1
From:
Posts: 24
implementation of ocsort
Hi

Proud to present an implementation of ocsort
Here a light presentation :

OCSort 0.0.1

OCSort is an open source sort tool, which implement a subset of the functionnality of the Microfocus(c) MFSORT(c) utility.
This program is distributed under the GNU General Public License. See COPYING for details.
Functionnality supported :
SORT FIELDS (only CH and BI type of field)
INCLUDE COND
OMIT COND
USE (multiple file, and only sequential fixed record length)
GIVE (just one file, and only sequential fixed record length)
OUTREC FIELDS (not everythin)
SUM FIELDS


Source can be found here :
http://www.add1tocobol.com/tiki-download_file.php?fileId=74

Regards,
Angus
btiffin
Posted on: 2010/2/16 0:31
Home away from home
Joined: 2008/6/7
From: CANADA
Posts: 737
Re: implementation of ocsort
Angus;

Thanks, compiled clean here. Umm, need to beg favours now though. Do you have a short usage example? For those of us denied MFSORT experience?

And, I'd like to tech chat on your .l and .y source code. As the Pakleds explained in STNG, "We want your computer things", "We like things that make us go" ;)

Cheers,
Brian
Angus
Posted on: 2010/2/16 10:35
Not too shy to talk
Joined: 2009/12/1
From:
Posts: 24
Re: implementation of ocsort
MfSort is microfocus clone of IBM ICEMAN (on MVS).

This is a sample :

ocsort sort fields"(1,5,CH,A,11,4,CH,A)" use inputfile record f,391 org sq give outputfile org sq

This will sort the file "inputfile", a fixed length file (391 byte each record, organization sequential), and create a file "outputfile" sorted (which is of the same type). The sort fields are :
(start, length, type, direction)
=> start=1
=> length=5
=> type = character (you can sort on comp3 fields, but ocsort don't handle it)
=> direction = ascending (or descending)
It's like an order by.
The omit/include condition allow to remove record from the file (ex if character number 5 of this record is 'F', omit the record). You can use and, or, greater than...)

I'm not an expert as using bison / flex (gnu tools to parse grammar language, opencobol use it to parse the cobol), but i will be happy to chat with you.
I don't understand the end of the sentence

Angus

btiffin
Posted on: 2010/2/17 5:26
Home away from home
Joined: 2008/6/7
From: CANADA
Posts: 737
Re: implementation of ocsort
"end of the sentence" That was me being funny? It's from an episode of Star Trek the Next Generation, Pakleds are thugs, acting helpless then snagging technology. I've always used "We want your computer things" as a praise when first-person, and a derogatory in third person. It was praise here.

And yeah, I was curious about your Flex and Bison skills, as OpenCOBOL may be able to leverage that expertise, (as good Pakleds would). I put a fair whack of REPORT SECTION parsing into cobc/parser.y but there are a few places that need, umm, bigger better logic. ;)

Have you had a chance to look through the cobc source code? I hope to pull off something like http://opencobol.add1tocobol.com/docs/cobc.html for the full tarball as a favour to Roger some day. Ahh, someday.

And thanks for the how-to on ocsort, time to play.
$ time dd if=/dev/urandom of=inputfile bs=391 count=100000
100000+0 records in
100000+0 records out
39100000 bytes (39 MB) copied, 16.0195 s, 2.4 MB/s

real    0m16.043s
user    0m0.028s
sys     0m15.981s
$ time ./ocsort sort fields"(1,5,CH,A,11,4,CH,A)" use inputfile record f,391 org sq give outputfile org sq
INPUT FILE :
        inputfile FIXED (391,391) SQ
OUTPUT FILE :
        outputfile FIXED (0,0) SQ
SORT FIELDS : (1,5,CH,A,11,4,CH,A)
Sort OK

real    0m0.790s
user    0m0.388s
sys     0m0.376s
$ ./verify
done


Where verify.cob is
      *> ***************************************************************
       identification division.
       program-id. verify.

       environment division.
       input-output section.
       file-control.
           select inputfile
           assign to "outputfile"
           organization is sequential.

       data division.
       file section.
       fd inputfile.
           01 indata pic x(391).

       working-storage section.
       01 lastrec pic x(391).

      *> ***************************************************************
       procedure division.
       open input inputfile
       move low-values to lastrec

       perform forever
           read inputfile
               at end
                   close inputfile
                   display "done" end-display
                   stop run
               not at end
                   if lastrec(1:5) greater than indata(1:5)
                       display "out of ascending order" end-display
                   end-if
                   move indata to lastrec 
           end-read
       end-perform

       goback.
       end program verify.

When verify.cob was changed to ASSIGN "inputfile" it output about 49,000 out of orders, in paired lines, so the sort did some work on the random file.

Need to run more tests, but this seems like a nice little engine Angus, 100 thousand records in 0.8 on my little P4.

Cheers,
Brian
Angus
Posted on: 2010/2/17 8:17
Not too shy to talk
Joined: 2009/12/1
From:
Posts: 24
Re: implementation of ocsort
For the sort, this is the qsort function of the libc which do the job. It loads the entire file in ram, but ram is cheaper now.

I will look in the cobc source, but i like you to said me what is wrong...

For the Star Trek Next Generation. , i'm a big fan (have & see all the episodes). I remember this episode, when alien try to kidnap Jordi Laforge, to repair these old ship. But i don't see it in VO...

Regards,
Angus
btiffin
Posted on: 2010/2/26 4:01
Home away from home
Joined: 2008/6/7
From: CANADA
Posts: 737
Re: implementation of ocsort
Angus;

I referenced your sorter in the FAQ. Now I realize I didn't really ask how you felt about that. Feel free to tell me to change/update the entry.

I was thinking about maybe creating an ocsort Pygments syntax highlighter, and throwing in a few more samples.

Cheers,
Brian
Angus
Posted on: 2010/2/26 8:38
Not too shy to talk
Joined: 2009/12/1
From:
Posts: 24
Re: implementation of ocsort
Hi

I have no problem with that.
But this is just a proposal. A beta version. I had in mind "Release early, release often". Perhaps rewrite the parser code should be done (remarks are welcomed)

Regards,
Angus

btiffin
Posted on: 2010/2/27 5:15
Home away from home
Joined: 2008/6/7
From: CANADA
Posts: 737
Re: implementation of ocsort
Angus; thanks for the proposal. :)

A few of us from add1tocobol.com discussed this very thing a while back; a sorter/filter/file manip thingy. This is more than a perfect start.

On the next FAQ update I'll make sure to date the entry and put in a beta stamp (for now).

Cheers,
Brian
Threaded | Newest First Previous Topic | Next Topic | Top

Register To Post
 
Copyright (C) 2005 The OpenCOBOL Project. All rights reserved.
Powered by Xoops2 | PHP | MySQL | Apache
ocean-net