Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do Loop problem

Status
Not open for further replies.

MikeL91

Programmer
Feb 8, 2001
100
US
I am trying to replace a field called SEL with a flag ('Y') for up to the value in a matched field (IDcode). Everything seems to be working ok, but when the idcode changes I can not figure out where to clear my counter. Mental block here please help.

here is the code:

select Input
go top
scan while !eof()
*
*
if seek(Input.IDcode,"SelectCnt")
nSelQty = SelectCnt.Qty
Select SelectCnt
Do While SelectCnt.Idcode = Input.IDcode
IF nUpdates <= nSelQty
select Input
nUpdates = nUpdates +1
replace Input.Sel with 'Y'
select SelectCnt
Endif
skip
Enddo
Select Input
Endif
endscan
 
Not sure this answers your question, but here are a few coding suggestions.

select Input
*go top Scan automatically starts at the top
scan && and automatically checks for eof() while !eof()
*
*
if seek(Input.IDcode,"SelectCnt")
nSelQty = SelectCnt.Qty
Select SelectCnt
*Do While SelectCnt.Idcode = Input.IDcode
SCAN WHILE SelectCnt.Idcode = Input.IDcode && faster than DO WHILE
IF nUpdates <= nSelQty
* select Input no need to switch tables
nUpdates = nUpdates +1 && what is nUpdates?
replace Input.Sel with 'Y'
*select SelectCnt
Endif
*skip
*Enddo
ENDSCAN
*Select Input - not necessary.
Endif
endscan

Regards,
Jim
 
I am not sure what you are trying to do? How many records for one IdCode you have in Input?
Also did you want to set Sel = [Y] for ALL equal IdCodes in Input (if you have more that one) if nUpdates > Qty in SelectCnt. Also why you use Qty only from FIRST record in SelectCnt?

Borislav Borissov
 
wow, those suggestions will not only help me here, but moving forward, thank you.

nUpdates is just a variable I initiate to 1 in the begining. just a counter.

qty is the same for all like values in the field Idcode, it is a count of how many I need to select from the big file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top