Home > Archive > Cobol > September 2004 > Reading Indexed Files Backwards
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Reading Indexed Files Backwards
|
|
|
| I could have sworn that in COBOL class, we did something like this...
move high-values to my-key
start my-file
key not > my-key
read my-file previous record
To read an indexed file backwards. However, today we were looking at
the manual for the compiler, and it didn't have this form of the read
statement in it. Am I imagining things? Is there a way to read an
indexed file backwards (in effect, a descending key)?
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ LXi0007@Netscape.net ~
~ _____ / \ | ~ http://www.knology.net/~mopsmom/daniel ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ I do not read e-mail at the above address ~
~ Please see website if you wish to contact me privately ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e ~
~ h---- r+++ z++++ ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
| |
| JerryMouse 2004-09-28, 3:55 am |
| LX-i wrote:
>
> darnit... That's what we used in class. crud - any ideas on how to
> make a descending key? XOR against high-values before writing the
> records? ;)
Sure, that'll do it. You could even make it an alternate key and read in
either direction.
| |
|
| William M. Klein wrote:
> For which compiler?
>
> (Many '85 Standard compilers had this as an extension. It is in the '02
> Standard as "processor dependent")
Unisys UCS COBOL (85)
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ LXi0007@Netscape.net ~
~ _____ / \ | ~ http://www.knology.net/~mopsmom/daniel ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ I do not read e-mail at the above address ~
~ Please see website if you wish to contact me privately ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e ~
~ h---- r+++ z++++ ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
| |
| James J. Gavan 2004-09-28, 3:55 am |
| LX-i wrote:
> Robert Wagner wrote:
>
>
>
> That's a good idea about all 9's - I'll see if the guy is using a
> numeric field. Thanks!
>
>
Daniel,
Robert rang a bell - so a follow-up. This of course depends upon what
you want to do. But going back some 25 years, RM/COBOL ('74) only ISAM,
Relative and Sequential - and NO Sorts - not even from Radio Shack O/S
(TRSDOS).
I had a need to print reports in Groups, ASCENDING by main Group
Category #, but DESCENDING for individual items by loss values. So
using an ISAM key (Key1 + Key2), somewhat crude but given losses, to
three decimals of an inch -0.333, -0.444, -0.555 :-
Key1 = Group Category :
Key2 = Loss
1000 + (-0.555) = key2 999.445
1000 + (-0.444) = key2 999.556
1000 + (-0.333) = key2 999.667
Above of course assumes you are creating the file Key from scratch and
are after the above sequencing for a sequential ISAM read.. As I said
depends upon your options. Given a hard-coded file PrimeKey you could as
an alternative generate an ISAM 'Dictionary' :-
01 DictionaryRecord.
05 PrimeKey.
10 Category pic 9(02).
10 Loss pic 9(06).
05 OriginalKey pic x(??????)..
then read the DictionaryRecord sequentially accessing the OriginalKey
from your other file.
Jimmy, Calgary AB
| |
| James J. Gavan 2004-09-28, 8:55 am |
| LX-i wrote:
> James J. Gavan wrote:
>
>
>
> darnit... That's what we used in class. crud - any ideas on how to
> make a descending key? XOR against high-values before writing the
> records? ;)
>
>
If you have mag tapes - could always try rewinding them :-P
| |
|
| Robert Wagner wrote:
> On Thu, 23 Sep 2004 18:01:33 -0500, LX-i <lxi0007@netscape.net> wrote:
>
>
>
>
> The most common need for reverse order is the date portion of a key,
> for example a price file keyed by 'part-number, effective-date'. In
> that case, subtract the date from 99999999. To restore it, subtract
> the file date from 99999999.
>
> XOR (against 7F7F) is logically correct, but will produce characters
> nearly impossible to read or edit if you have to work with raw
> records.
That's a good idea about all 9's - I'll see if the guy is using a
numeric field. Thanks!
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ LXi0007@Netscape.net ~
~ _____ / \ | ~ http://www.knology.net/~mopsmom/daniel ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ I do not read e-mail at the above address ~
~ Please see website if you wish to contact me privately ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e ~
~ h---- r+++ z++++ ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|