Hello everyone,

I have a method whose purpose is to delete the values from one array (a1)
from another array (a2).
So I

   1. Sort both arrays
   2. Loop through the the array containing the values (a1) to be deleted
   1. Use Find in Array to see if the value in a1 is present in a2
         1. If yes, use Count in Array to determine the number to be deleted
         2. Use DELETE FROM ARRAY to the number of elements found

I have found situations in v13.3, v13.6 and v15.0 where the number of
elements counted in step 2.1.1 does not match the Debug windows display of
the array.

The basic code is below. And it works at least 90% of the time.

Any ideas would be appreciated! I have written a replacement for this
function but I am having a hard time believing that something this basic
doesn't work...

Thanks,
Alan Tilson

$pAr_DeleteFrom:=$1
$pAr_ValuesToDelete:=$2
$count_i:=$3

SORT ARRAY($pAr_DeleteFrom->;>)
SORT ARRAY($pAr_ValuesToDelete->;>)

$start:=0
For ($el;1;Size of array($pAr_ValuesToDelete->))

$_ValueToDelete:=$pAr_ValuesToDelete->{$el}
$start:=Find in array($pAr_DeleteFrom->;$_ValueToDelete;$start)
If ($start=-1)

$start:=0

Else

$count_toDelete:=Count in array($pAr_DeleteFrom->;$_ValueToDelete;$start)

DELETE FROM ARRAY($pAr_DeleteFrom->;$start;$count_toDelete)

End if

End for
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to