Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
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++++                                            ~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~


Report this thread to moderator Post Follow-up to this message
Old Post
LX-i
09-28-04 08:55 AM


Re: Reading Indexed Files Backwards
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.



Report this thread to moderator Post Follow-up to this message
Old Post
JerryMouse
09-28-04 08:55 AM


Re: Reading Indexed Files Backwards
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++++                                            ~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~


Report this thread to moderator Post Follow-up to this message
Old Post
LX-i
09-28-04 08:55 AM


Re: Reading Indexed Files Backwards
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

Report this thread to moderator Post Follow-up to this message
Old Post
James J. Gavan
09-28-04 08:55 AM


Re: Reading Indexed Files Backwards
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

Report this thread to moderator Post Follow-up to this message
Old Post
James J. Gavan
09-28-04 01:55 PM


Re: Reading Indexed Files Backwards
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++++                                            ~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~


Report this thread to moderator Post Follow-up to this message
Old Post
LX-i
09-28-04 01:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:35 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.