` Printed Icetips Article

Icetips Article



Files, drivers etc.: Loop a file within a loop on that same file
2003-05-08 -- Michael Ware
 
Newsgroups: softvelocity.products.c55ee

> Is this possible :
> Having a file loen_fast
> SET(LOF:key,LOF:key)
> loop
>     if access:loen_fast.next() then break.
>         ! Do a lot of things on this loen_fast
>         LOF:field2 = 'Something in this record of loen_fast'
>         set(LOF:Key2,LOF:key2)
>         loop
>             if access:loen_fast.next() then break.
>                 !Update some Loen_fast records        end
> end
>
> IE : Inside a loop of the records in one sort order, i want to make a lopp
> in another sort order without interrupting the 'Outside' loop.


I've done this a few times.  Works like this:

SET(LOF:key,LOF:key)
loop
    if access:loen_fast.next() then break.
        ! Do a lot of things on this loen_fast
        HldPos = Position(LOF:key)
        LOF:field2 = 'Something in this record of loen_fast'
        set(LOF:Key2,LOF:key2)
        loop
            if access:loen_fast.next() then break.
                !Update some Loen_fast records
        end
        reset(LOF:key,HldPos)
        access:loen_fast.next()
end

The trick is you need to issue a next after the reset to get back to were
you were.

-Mike



Printed May 5, 2024, 9:32 am
This article has been viewed/printed 35124 times.
Google search has resulted in 19 hits on this article since January 25, 2004.