We use a method SelectItemFromBB, see below, to retrieve either an
array of record numbers or values of a key of currently selected
bBrowser lines. Although it works 10.000 of times, we had a very odd
issue which makes me wondering if the code below could go wrong.
First, we call this method and add the recordnumbers in a temp
database passed to a re****t to print a packing slip. The customer sent
us a PDF where the 16 lines have partly been duplicated. Not that they
are just printed a second time, we see 1-6 ok, then it repeats 1 and
6, then 9-16 ok and then some random repeats.
A logic explanation is that the temp database wasn't properly zapped
but from logging we found (within a short time when several action
have been performed on the selection) that every of this action, each
calling the method SelectedBBItems again, the same order and
incorrect selection of records has been used in methods like
self:DoSomethingWithThisRecordAndLogIt() in the code below. We can see
without doubt that the same record has been used in the for-next for
12 out of 16 items printing, reserving for delivery and ****pping those
12 items double.
We've studied it in length but could not find any other explanation
than that SelectedBBItems was able to add records a second time in the
array it returns. But we have no idea how....
It can be avoided (adding an ascan) but we just wondered: could there
be anything in the code below causing it? Or does someone have this
experience as well?
Dick van Kooten
The method is called a few times like this:
ASel := SELF:SelectedBBItems (SELF:oDCbBrowser, #Anyfield, TRUE)
nLen:=ALen(aSel)
FOR ni:= 1 UPTO nLen
olServer:Goto(aSel[ni])
self:DoSomethingWithThisRecordAndLogIt()....// this used and
logged that 12/16 records where used twice
NEXT
METHOD SelectedBBItems (oControl, sSymCol, lReturnRecnos) CLASS Window
//#s Returns array with selected bBrowser items Added in class
1-9-2004
//#p oControl=bBrowser; symcol = column to return array lReturnRecnos
LOCAL nRecNo AS DWORD
LOCAL aValues := {} AS ARRAY
LOCAL uRecord AS USUAL
uRecord := oControl:RecordSave() // Keep current record
oControl:Server:SuspendNotification ()
nRecNo := oControl:SelectionFirstRow ()
DO WHILE nRecNo > 0
IF lReturnRecnos
AAdd (aValues, nRecno)
ELSE
oControl:Server:GoTo (nRecNo)
AAdd (aValues, oControl:Server:FIELDGET (sSymCol))
ENDIF
nRecNo := oControl:SelectionNextRow ()
ENDDO
oControl:RecordRestore(uRecord) // Restore record
oControl:Server:ResetNotification ()
RETURN aValues


|