In message <[EMAIL PROTECTED]>, Joshua Gallant <[EMAIL PROTECTED]> writes >When running through an array with a for next loop the last item >processed isn't remembered so the program needs to traverse the entire >array for each record and will slow down as you get to records later in >the process.
I thought UV had optimisations so that (as long as it is FIELDS) the last item processed IS remembered and it carries on scanning from where it left off. > >Instead of this: > >A11 = DCOUNT(IN.TAB,@AM) > >FOR A1 = 1 TO A11 > IN.LINE = IN.TAB<A1> > SWAP @VM WITH @AM IN IN.LINE > CUST.NUM = IN.LINE<1> > CUST.DESC = IN.LINE<2> >NEXT A1 > Seeing as this snippet does nothing much, I'd guess that the problem is actually somewhere in the code you've snipped - do you assign back to IN.TAB at any point? That *really* will get slow. >Try something like this instead: > >LOOP >REMOVE IN.LINE FROM IN.TAB SETTING MARK > SWAP @VM WITH @AM IN IN.LINE > CUST.NUM = IN.LINE<1> > CUST.DESC = IN.LINE<2> >WHILE MARK DO >REPEAT > >That will keep track of where you were in the array and pick up where >you left off. > >Let me know how that works out for you. > I'd do the following (INFORMATION-style flavours only!) A11 = DCOUNT(IN.TAB,@AM) DIM IN.TAB.M(A11) MATPARSE IN.TAB.M FROM IN.TAB, @FM FOR A1 = 1 TO A11 IN.LINE = IN.TAB.M(A1) SWAP @VM WITH @AM IN IN.LINE CUST.NUM = IN.LINE<1> CUST.DESC = IN.LINE<2> NEXT A1 If you've been assigning to IN.TAB, you can then get it all back with MATBUILD IN.TAB FROM IN.TAB.M, @FM (Check my syntax - I've probably got MATPARSE/MATBUILD wrong - I look them up in the manual when I need them :-) Something to bear in mind ... using dimensioned arrays will ALWAYS beat dynamic arrays for speed. Which is more important to you? The flexibility of dynamic or the speed of dimensioned? And in PI-style accounts you can have the advantages of both - dimensioned arrays can be defined "on the fly", at a small cost in clarity-of-code. With small arrays I can never be bothered with dimensioned arrays. As soon as I start heavily manipulating arrays, or they start getting big, I look at dimensioned arrays and wonder "are they worth it". Sometimes they are, sometimes they aren't. Looking at your case, they almost certainly are! Cheers, Wol -- Anthony W. Youngman <[EMAIL PROTECTED]> 'Yings, yow graley yin! Suz ae rikt dheu,' said the blue man, taking the thimble. 'What *is* he?' said Magrat. 'They're gnomes,' said Nanny. The man lowered the thimble. 'Pictsies!' Carpe Jugulum, Terry Pratchett 1998 Visit the MaVerick web-site - <http://www.maverick-dbms.org> Open Source Pick ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/
