Joshua Gallant wrote:
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.

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

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.


Unfortunately, that won't quite work.

The REMOVE statement removes the next element, and since he's got embedded attributes (@AM), that approach will return the attribute instead of the entire line.

Unfortunately. And particularly since the approach you recommend is one that I like, and use a lot 'cause you're absolutely correct about the indexing of the elements.

However, this will work:  (at least on Universe):
0001 IN.TAB = "" 0002 IN.TAB:= "NAME-ONE": @VM: "DESC-ONE": @VM: "1A": @VM: "1B" 0003 IN.TAB:= @AM: "NAME-TWO": @VM: "DESC-TWO": @VM: "2A": @VM: "2B" 0004 IN.TAB:= @AM: "NAME-THREE": @VM: "DESC-THREE": @VM: "3A": @VM: "3B": @VM: "3C" 0005 0006 REM1 = 999 0007 LOOP WHILE REM1 NE 0 0008 REMOVE CUST.NAME FROM IN.TAB SETTING REM1 0009 CRT "CUST.NAME: ": CUST.NAME 0010 REMOVE CUST.DESC FROM IN.TAB SETTING REM1 0011 CRT "CUST.DESC: ": CUST.DESC 0012 LOOP WHILE REM1 EQ 3 0013 REMOVE EXCESS FROM IN.TAB SETTING REM1 0014 CRT "REMOVED ": EXCESS 0015 REPEAT 0016 CRT 0017 REPEAT 0018 STOP >RUN ADE.BP TT CUST.NAME: NAME-ONE CUST.DESC: DESC-ONE REMOVED 1A REMOVED 1B


CUST.NAME: NAME-TWO CUST.DESC: DESC-TWO REMOVED 2A REMOVED 2B


CUST.NAME: NAME-THREE CUST.DESC: DESC-THREE REMOVED 3A REMOVED 3B
REMOVED 3C


--
Allen Egerton
aegerton at pobox dot com
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to