× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: finding a suitable key
  • From: "Juris Krikis Jr." <juris.rfb@xxxxxxxxxxx>
  • Date: Thu, 28 Aug 1997 11:25:11 +0300

Reading the responses I figured out that I really was not making myself
clear the first time. I'll try again, if I may. Let's say we have an
externally described file. The DDS specification looks approximately
like this:
A       R FIL_REC
          FIL_KEY       4S      TEXT('unique primary key')
          FIL_DTA      80A      TEXT('the data')        
        K FIL_KEY

We do have some records already there:
FIL_KEY FIL_DTA
------- -------------------------------
 1      'one'
 4      'record FOOBAR'
 0      'null record'
 99     'some record'
 2      'BAR'

Now, let's suppose we need to insert a record... We want to find a
unused primary key for it. What I do now is approximately:

FFil    UF A E       K DISK
DKey      S                4S 0
C               DoW     *In40 = *Off
C               Add     1               Key
C       Key     Chain   Fil_Rec                         40
C               EndDo
C               Move    Key             Fil_Key
C               Move    Data            Fil_Dta
C               Write   Fil_Rec

This kinda gets the job done and we happily add a record with key '3'
(we skipped the '1' and '2' here) there. I don't really like this code,
because it takes a few lines to write and has to chain through the whole
file to find the next unused key. It doesn't recognize keys of 0. And it
changes the buffers (whatever was in Fil_Dta is modified). I was just
wondering if this could be written easier/better/smarter? Any ideas?

                        Kind regards, Juris.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  Questions should *
* be directed to the list owner / operator: david@midrange.com          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.