[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [open-cobol-list] LINE SEQUENTIAL records.
From: |
vince coen |
Subject: |
Re: [open-cobol-list] LINE SEQUENTIAL records. |
Date: |
Sun, 1 Jun 2008 12:04:39 +0100 |
User-agent: |
KMail/1.9.6 |
Hi;
On Saturday 31 May 2008, John Culleton wrote:
> INherently LINE SEQUENTIAL files have variable length records. When I
> read in a record of say 50 characters into a FD description of say
> X(80) what happens to the EOL character? Is it stripped off?
For normal cobol compilers and I would assume OC the EOL would be stripped
when moved into the FD area.
In programs that I have created in OC I have not noticed it so I have to
assume that is indead stripped. If you need to detect EOL there are a few
tricks you can try:
1. preload buffer area with 'FF' or '00' then read in a record then search
from the end looking for the first non 'FF' than thats your last char.
2. In cobxref I use the functions to read a record in having preloaded 'FF'
then test as above in 1.
Smippet of code used for read-a-record etc:
-------------------------------------------------------------------------------------
372600 zz600-Get-A-Record.
372700*
372800* Now to extract a record from buffer and if needed read a block
372900* then extract
373000*
373100 move spaces to Fht-Current-Rec (Fht-Table-Size).
373200 add 1 to Fht-Block-OffSet (Fht-Table-Size) giving g.
373300*
373400* note size is buffer size + 2
373500*
373600 unstring Fht-Buffer (Fht-Table-Size) (1:4097)
373700 delimited by x"0A" or x"FF"
373800 into Fht-Current-Rec (Fht-Table-Size)
373900 delimiter Word-Delimit3
374000 pointer g.
374100*
374200* Get next Block of data ?
374300*
374400 if Word-Delimit3 = x"FF"
374500 and g not < 4097
374600 add Fht-Block-OffSet (Fht-Table-Size)
374700 to Fht-File-OffSet (Fht-Table-Size)
374800 perform zz600-Read-A-Block
374900 go to zz600-Get-A-Record.
375000* EOF?
375100 move 1 to Fht-Pointer (Fht-Table-Size).
375200 if Word-Delimit3 = x"FF"
375300 move 1 to Fht-sw-Eof (Fht-Table-Size)
375400 go to zz600-Exit.
375500* Now so tidy up
375600 subtract 1 from g giving Fht-Block-OffSet (Fht-Table-Size).
375700 go to zz600-exit.
375800*
375900 zz600-Read-A-Block.
376000 move all x"FF" to Fht-Buffer (Fht-Table-Size).
376100* if Fht-File-Size (Fht-Table-Size) < 4096 and not = zero
376200* move Fht-File-Size (Fht-Table-Size)
376300* to Fht-Byte-Count (Fht-Table-Size).
376400 call "CBL_READ_FILE" using
376500 Fht-File-Handle (Fht-Table-Size)
376600 Fht-File-OffSet (Fht-Table-Size)
376700 Fht-Byte-Count (Fht-Table-Size)
376800 Cbl-Flags
376900 Fht-Buffer (Fht-Table-Size).
377000 if Return-Code not = zero
377100 display Msg15 Return-Code
377200 go to zz600-Exit.
377300* just in case all ff does not work
377400 move x"FF" to Fht-Buffer (Fht-Table-Size) (4097:1).
377500 move zero to Fht-Block-OffSet (Fht-Table-Size).
377600 subtract Fht-Byte-Count (Fht-Table-Size)
377700 from Fht-File-Size (Fht-Table-Size).
377800 zz600-Exit.
377900 exit.
--------------------------------------------------------------------------------------------
Hope it helps,
Vince.
- Re: [open-cobol-list] LINE SEQUENTIAL records.,
vince coen <=