How to find (and modify) entry before last?

infonoteinfonote Member Posts: 233
Hi,

I am trying to use the penultimate entry in a REPEAT...UNTIL loop.
I am trying to use the following, however it is not working, it is not entering the code part.
I := record.COUNT.

REPEAT

IF (I = (I-1)) THEN BEGIN

...
.... code
END

UNTIL record.NEXT = 0;

How can I enter the code part if it is the penultimate entry?

Thanks

Comments

  • reijermolenaarreijermolenaar Member Posts: 256
    'I' will never be equal to '(I-1)' ... :-k

    You could do the following to get the second last:
    record.FINDLAST;
    record.NEXT(-1);
    
    Reijer Molenaar
    Object Manager
  • matttraxmatttrax Member Posts: 2,309
    The NEXT keyword takes an optional parameter, steps. Similar to how you would increment a do...while loop counter in object oriented programming.

    Instead of counter++ or counter += 5 you can do NEXT, NEXT(1), NEXT(-1), or NEXT(variable). If you pass it an integer it will jump that many records.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    The quesitons are why do you need the penultimate entry, how can you identify this entry, and what do you want to do to it?
    David Singleton
Sign In or Register to comment.