Hello,
this is driving me crazy :(
I have a screen that lets the user add/remove multiple items to an assembly.
The items are stored in an array whilst they edit and then stored in the
main table if they save.
The save routine looks like this:
SELECT pri_det
m.arrayref=1
m.arraylen=ALEN(priceinf,1)
SCAN FOR wk_ref = m.ref
IF m.arrayref<=m.arraylen
* already existing record - replace contents
REPLACE pri_det.saparticle WITH RIGHT(priceinf[m.arrayref],6)
m.arrayref=m.arrayref+1
ELSE
* array has fewer records than table - delete record
DELETE
ENDIF
ENDSCAN
* add any remaining records from array to table
DO WHILE m.arraylen>=m.arrayref
INSERT INTO pri_det VALUES (m.ref,RIGHT(priceinf[m.arrayref],6))
m.arrayref=m.arrayref+1
ENDDO
Sometimes when they remove items, this doesn't work correctly and the
SCAN..ENDSCAN doesn't loop all the records in its FOR clause. Does anyone
know WHY!?!!
1) There is no filter set.
2) I've recreated the indexes with INDEX ON. (although I haven't tried a
SCAN.. NOOPTIMIZE yet)
3) I've pulled that routine out into a separate program (working on the same
table) to try to reproduce and it seems to work fine.
4) I wrote a little program that SCANS the same clause just doing an
incremental count to a vraible and then display the result in a wait window.
I used my screen to remove some items and broke the save routine just before
the SCAN. At this point I ran my counting program - it showed a SCAN FOR
wk_ref=m.ref count of 5 records. When then went on to single step the save
routine it only SCANned 3.
What on earth could possibly be wrong here?
--
TIA
Andrew Howell