General information
Category:
Coding, syntax & commands
Title:
Scan endscan skipping last record
I have a scan/endscan loop that I am using to update records in a table. The routine works fine until the last record. It skips updating the last record, no matter how many records It processes. I am using scatter/gather to update the records. I placed a wait window just before the gather, so I know the loop is executing on the last pass, and I know that the variables exist in memory. It's as if the table doesnt get updated until after the loop begins again???
I had a similar situation some time ago, but I was appending records. I placed a "GO BOTTOM" command just before the gather and it solved the problem. Obviously, I can't do that here since I'm not appending records. I tried a "GO RECNO()" but that didnt help. I'm just not understanding why it's skipping the last update. My code Follows:
SELECT 'diecmm'
GO TOP IN 'diecmm'
SCAN FOR !(diecmm.imported)
*replace diecmm.imported WITH .t.
SCATTER memvar
SELECT 'dieactualdata'
LOCATE FOR dieactualdata.jobnum=m.jobnum AND dieactualdata.itemnum=m.itemnum
IF FOUND()
IF m.atd1>0
SELECT 'dieparams'
LOCATE FOR dieparams.jobnum=m.jobnum
IF FOUND()
m.atl1=dieparams.tl1/2
IF m.atd2>0
m.atl2=dieparams.tl2/2
endif
ELSE
thisform.omessage.warning('Parameters are missing for: '+ALLTRIM(m.jobnum))
endif
ENDIF
SELECT 'dieactualdata'
WAIT STR(m.itemnum)+' '+STR(m.aol,8,5) window
GATHER memvar
ELSE
lcError=lcError+CHR(040)+ALLTRIM(diecmm.jobnum)+CHR(032)+ALLTRIM(STR(diecmm.itemnum))+CHR(041)+ CHR(032)
endif
ENDSCAN
IF !EMPTY(lcError)
thisform.omessage.warning('Actual data records were missing, so the import failed for: '+ALLTRIM(lcError))
endif
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only