[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnubol: Record delimiter clause and parse order



Tim Josling wrote:
> 
> Matthew,
> 
> Parsing
> *******
> 
> Where there are many clauses, I would use something like this.
> 
> select_clause:
> SELECT optional_clause_opt assign_clause
> select_sub_clause_rep_opt
> ;
> 
> _rep (obvious)
> _opt (obvious)
> 
> select_sub_clause:
>  access_mode_clause
> |file_status_clause
> |lock_mode_clause
> |organization_clause
> |padding_char_clause
> |record_delim_clause
> |reserve_area_clause
> |sharing_clause
> ;
> 
> The benefit is that you get maximum recognition out of the parser
> and if the clauses are out of order you don't get a dumb 'syntax
> error' message.
> 
> You then have the option of accepting the clauses out of order or
> doing a manual check. You would probably only do the manual check
> only in pedantic mode, at which time you can put out a good
> message.
> 
> Record Delimiter
> ****************
> 
> The record delimiter clause is optional, in ANSI 85. "Record
> delimiter is standard-1" is only allowed for mag tapes.
> 
> On the general question of the sequential formats I would suggest
> that we do as the Romans do, which as far as I know (please
> someone knowledgeable correct me on this).
> 
> - ORGANISATION IS SEQUENTIAL
> means that either it is fixed records with no delimiter or
> variable records with some record prefix. Someone may be able to
> tell us what is the format used by Merant or FJ. The IBM
> mainframe format can be ignored for now. It is a horrible mess.
> 
> - ORGANISATION iS LINE-SEQUENTIAL
> means that it is delimited by CRLF or CR or LF depending on te
> platform (whatever fread regards as "\n"). This would be flagged
> as an extension in pedantic mode and the keyword line-sequential
> would be just another word in standard cobol-84 mode (see
> cobctok.def).
> 
> I don't know why they did not use 'record delimiter is newline'
> instead of inventing line-sequential, but they did.
> 

For shits-n-grins, and personal aggrandizement, I did a little test in
MF today at work.  Sequential is sequential, with no delimiters,
assuming fixed length records.  Line sequential is delimited by "\r\n"
(hex 0D 0A).  At least, that's how they come out on OS/2.  So, for fixed
length sequential, that's the way I'll do it.  Line sequential I'll
throw in because it seems that so many non-mainframe compilers seem to
advertise support it--"Shop here!! We support MicroFocus' non-standard
proprietary extensions!!"

> Someone mentioned that fixed vs variable changes the filling of
> the records. True.
> 

I also did a couple of variable length writes, so I could get an idea of
what MF does with writing variable length files.  I'm hard pressed to
decipher them, however, even with a hex editor.  I've attached it, and
the program I used to write it.  I can understand the basic
structure--starts out at 6 bytes, then increases to 10 bytes, and
presumably would add another 4 bytes when rec-len reaches 14, to give 18
bytes, and so on. Any pointers on interpreting would be very much
appreciated.  We don't really use variable length records in files. 
Actually, we do much more DB work than we do file IO at all...


> Don't forget we have the option to ignore clauses that have no
> meaning in our environment. Eg we can say memeory-size is
> ignored, same for record-delimiter. This is important for running
> code for other compilers.
> 

Of course. ;)  I would like to support as much as we can, though, as
long as it's appropriate for the operating system.  

Gahh!! never really thought about all the work that goes on behind the
scenes in COBOL.  It really is an amazing language, notwithstanding
having over 400 reserved words.

BTW, for the attached file, I only attached the sequential variable
length file, and not the line sequential.  Not really much difference,
anyhow.

ciao,
-- 
Matthew Vanecek
Visit my Website at http://mysite.directlink.net/linuxguy
For answers type: perl -e 'print
$i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
*****************************************************************
For 93 million miles, there is nothing between the sun and my shadow
except me. I'm always getting in the way of something...
0~0005221510209500052215102095>2C 4@A@AA@AAA@AAAA@AAAAA@AAAAAA@AAAAAAA   @AAAAAAAA  @	AAAAAAAAA 
      * This is a stub driver for the IIMSW110 Order Open module
       IDENTIFICATION DIVISION.
       PROGRAM-ID.    omsfile.
       AUTHOR.        Matthew Vanecek
       DATE-WRITTEN.  05/15/00.
       DATE-COMPILED.
      *
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.  IBM-PC.
       OBJECT-COMPUTER.  IBM-PC.
      *
       INPUT-OUTPUT     SECTION.
       FILE-CONTROL.
           SELECT OUTPUT-FILE
                   ASSIGN          TO 'NOLINSEQ.TXT'
                   ORGANIZATION    IS SEQUENTIAL
                   FILE STATUS     IS FILE-STATUS.
                   
           SELECT VAR-LN-OUTPUT-FILE
                   ASSIGN          TO 'VARLNSEQ.TXT'
                   ORGANIZATION    IS LINE SEQUENTIAL
                   FILE STATUS     IS FILE-STATUS.
                   
           SELECT VAR-OUTPUT-FILE
                   ASSIGN          TO 'VARSEQ.TXT'
                   ORGANIZATION    IS SEQUENTIAL
                   FILE STATUS     IS FILE-STATUS.
                   
           SELECT OUTPUT-LINE-FILE
                   ASSIGN          TO 'LINESEQ.TXT'
                   ORGANIZATION    IS LINE SEQUENTIAL
                   FILE STATUS     IS FILE-STATUS.

       DATA DIVISION.
       FILE SECTION.
       FD  OUTPUT-FILE.
       01  DUMMY-REC            PIC X(50).

       FD  VAR-LN-OUTPUT-FILE
           RECORD IS VARYING IN SIZE
           FROM 1 TO 50 CHARACTERS
           DEPENDING ON REC-LEN.
       01  VAR-LN-DUMMY-REC     PIC X(50).
       
       FD  VAR-OUTPUT-FILE
           RECORD IS VARYING IN SIZE
           FROM 1 TO 50 CHARACTERS
           DEPENDING ON REC-LEN.
       01  VAR-DUMMY-REC        PIC X(50).
       
       FD  OUTPUT-LINE-FILE.
       01  DUMMY-REC-LINE       PIC X(50).

       WORKING-STORAGE SECTION.
      * KEY FIELDS FOR THE ORDER LINE - NEEDED FOR ALL METHODS
      *
       01 FILE-STATUS                          PIC  X(02) VALUE SPACES.

       01 REC-LEN                              PIC S9(04) COMP
                                                   VALUE ZEROS.

       01 VAR-DTL-LINE                         PIC X(50) VALUE SPACES.
       01 DETAIL-LINE.
           05  LINE-NO                         PIC 9(05) VALUE ZEROS.
           05  FILLER                          PIC X(45) VALUE
            ' LINE-THIS IS A TEST of (LINE)-SEQUENTIAL.'.
            
       PROCEDURE DIVISION.
       001-main section.
           display 'Starting program run.'.
           OPEN OUTPUT OUTPUT-FILE.
           DISPLAY 'file status is ' FILE-STATUS.
           OPEN OUTPUT OUTPUT-LINE-FILE.
           DISPLAY 'file status is ' FILE-STATUS.
           PERFORM VARYING LINE-NO FROM 1 BY 1
                   UNTIL   LINE-NO = 10
               WRITE DUMMY-REC         FROM DETAIL-LINE
               WRITE DUMMY-REC-LINE    FROM DETAIL-LINE
           END-PERFORM.

           MOVE ZEROS TO LINE-NO.

           OPEN OUTPUT VAR-OUTPUT-FILE.
           DISPLAY 'file status is ' FILE-STATUS.
           OPEN OUTPUT VAR-LN-OUTPUT-FILE.
           DISPLAY 'file status is ' FILE-STATUS.
           
           PERFORM VARYING LINE-NO FROM 1 BY 1 UNTIL LINE-NO = 10
               STRING
                   VAR-DTL-LINE DELIMITED BY SPACES
                   'A'          DELIMITED BY SPACES
                   INTO VAR-DTL-LINE
               END-STRING
               ADD 1 TO REC-LEN
               MOVE VAR-DTL-LINE TO VAR-DUMMY-REC
               WRITE VAR-DUMMY-REC
               WRITE VAR-LN-DUMMY-REC FROM VAR-DTL-LINE
           END-PERFORM.
           
           CLOSE OUTPUT-FILE.
           CLOSE OUTPUT-LINE-FILE.
           CLOSE VAR-OUTPUT-FILE.
           CLOSE VAR-LN-OUTPUT-FILE.
           STOP RUN.