× 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.



On Wed, 2005-08-24 at 22:43 -0700, Tony Carolla wrote:
> Thanks for checking this out. 
> 
> As far as I know, if the account you are using with SETGT is at the end of 
> the file, SETGT will not move the cursor. 
This would be a bug if it were true.


> But in your program, if you get a 
> duplicate key error, you just keep increasing the sequence number, until you 
> find an un-used sequence number. That would work. That is much less complex 
> than what I came up with. 

Just to be sure, I ran it in debug.  

With the test code I presented, *every* record is added to the end of
the file.  

When I step through the code, I check mseq# after each readpe and it's
exactly what you would expect it to be.  For example, when I'm planning
to write account 3 sequence 3, the code has retrieved via readpe account
3 sequence 2.

The only reason for the loop is the case where someone else writes your
sequence before you can.

As a further test, I updated the program and removed the loop.  This one
(without the loop) works just fine, but it assumes only one job is
updating the file at any one time.

Try it yourself when you have time.

     h dftactgrp(*no)
     h option(*srcstmt:*nodebugio)

     fmemo      if a e           k disk

     d addmemo         pr             5p 0
     d   acct#                       11p 0 const
     d   text                        35    const

      /free
         addmemo(1: 'memo 1-1');
         addmemo(1: 'memo 1-2');
         addmemo(1: 'memo 1-3');

         addmemo(3: 'memo 3-1');
         addmemo(3: 'memo 3-2');
         addmemo(3: 'memo 3-3');

         addmemo(2: 'memo 2-1');
         addmemo(2: 'memo 2-2');
         addmemo(2: 'memo 2-3');

         addmemo(4: 'memo 4-1');
         addmemo(4: 'memo 4-2');
         addmemo(4: 'memo 4-3');

         *inlr = '1';
      /end-free
      * Add a memo to the account
     p addmemo         b

     d addmemo         pi             5p 0
     d   acct#                       11p 0 const
     d   text                        35    const

     d success         s               n
     d result          s              5p 0

      /free
         mseq# = 0;
         setgt acct# memo;
         readpe acct# memo;

         macct# = acct#;
         mseq# = mseq# + 1;
         mtext = text;
         write memoa;

         result = mseq#;
         return result;

      /end-free
     p                 e

Regards,
Rich


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.