|
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 mailing list archive is Copyright 1997-2025 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.