> > > > > Does anyone know why my do while !EOF() loop will only do the first record and then exit even though there are alot more records in the source cursor?
> > > > >
> > > > >
> > > > > SELECT lineno, sono, item, loctid, qtyord-qtyshp AS qtyord, picked, whmap, RECNO("a") AS recno ;
> > > > > FROM (m0sotranf) a WHERE sono = lc_sono AND sostat=' ' AND sotype$" O" ;
> > > > > ORDER BY 1 INTO CURSOR C_first
> > > > > bROW
> > > > > GO TOP
> > > > > DO WHILE !EOF() && Will only go through first record then exit
> > > > > ln_memcount = MEMLINES(whmap)-1
> > > > > *IF ln_memcount > 1
> > > > > FOR i = 1 TO ln_memcount
> > > > >
> > > > > lc_str = MLINE(whmap, i)
> > > > > lc_chkitem = SUBSTR(lc_str, 1, 15)
> > > > > lc_pickloc1 = SUBSTR(lc_str, 16, 6)
> > > > > lc_pickq1 = VAL(SUBSTR(lc_str, 22, 5))
> > > > > lc_vndid1 = SUBSTR(lc_str, 27, 6)
> > > > > lc_pickloc2 = SUBSTR(lc_str, 33, 6)
> > > > > lc_pickq2 = VAL(SUBSTR(lc_str, 39, 5))
> > > > > lc_vndid2 = SUBSTR(lc_str, 44, 6)
> > > > >
> > > > > SELECT a_tmpf1
> > > > >
> > > > > APPEND BLANK
> > > > > REPLACE Lineno WITH c_first.lineno, ITEM WITH c_first.item, BOM WITH lc_chkitem, LOCTID WITH c_first.loctid, ;
> > > > > QTY WITH c_first.qtyord, pickloc1 WITH lc_pickloc1, pickq1 WITH lc_pickq1, VndID1 WITH lc_vndid1,;
> > > > > pickloc2 WITH lc_pickloc2, pickq2 WITH lc_pickq2, VndID2 WITH lc_vndid2
> > > > > REPLACE oqty WITH qty, opickloc1 WITH pickloc1, opickq1 WITH pickq1, OVndID1 WITH VndID1;
> > > > > opickloc2 WITH pickloc2, opickq2 WITH pickq2, OVndID2 WITH VndID2, recno WITH c_first.recno
> > > > >
> > > > > ENDFOR
> > > > > *ENDIF
> > > > > SKIP
> > > > > ENDDO
> > > > >
> > > > IS it because I have to change back to the original table before the
SKIP
or something to that effect?
> > >
> > > Let me clarify a bit more, I added a
SELECT C_first
right before the skip and it does go to the next record but then
SELECT a_tmpf1
gives a cannot find alias error after a random amount of records. I hate these kind of intermittant errors.
> >
> > If you use SCAN ALL ENDSCAN you shouldn't have the problem.
> >
> > KTB
>
> Hey Ken, don't you still have to set the active work area back with SCAN ... ENDSCAN? I agree that it's easier to use than the DO WHILE and it does the SKIP for you, but I think you still have to keep an eye on the work areas.
>
> ---
>
>
www.foxite.com - The Home of the Visual FoxPro Experts
Michael:
Actually, you do not - From VFP help...
SCAN ... ENDSCAN ensures that, upon reaching ENDSCAN, Visual FoxPro reselects the table that was current when the SCAN ... ENDSCAN loop began.
So, this code works fine...
SCAN ALL
? "TOP ",SELECT(),ALIAS()
? "TABLE2 ",RECNO("TABLE2")
SELECT TABLE1
GO BOTTOM
? "BOTTOM ",SELECT(),ALIAS()
ENDSCAN
The "TOP" print always prints TABLE1 and the "BOTTOM" statement always prints TABLE2.
KTB