#include "ltwrappr.h"
L_BOOL LBarCode::IsDuplicated (nIndex)
Returns a value that indicates whether the specified barcode is duplicated or not.
Index of a barcode within the class object's barcode data array. This is a zero-based index. nIndex must be >= 0 and less than the total number of barcodes read using LBarCode::Read.
Value | Meaning |
---|---|
TRUE | The specified barcode is duplicated. |
FALSE | The specified barcode is not duplicated. |
This function will determine whether the barcode at the specified index is duplicated within the class object's barcode data array.
To read in barcodes present in a bitmap, use the LBarCode::Read function.
Any index for which the class object's barcode data array contains valid data can be passed to the LBarCode::IsDuplicated function.
If the specified barcode is duplicated, you can get the first duplicated barcode using LBarCode::GetFirstDuplicated. To get the next duplicated barcode use LBarCode::GetNextDuplicated. Get the total number of duplicated barcodes using the LBarCode::GetDuplicatedCount function.
To find out how many sets of barcodes are duplicated, use the following:
int CBarCodeView::GetSetsCount(LBarCode * BarCode)
{
L_INT i, j, nTotalCount, nCount;
L_BOOL * pbVisited;
pBARCODEDATA pBarCodeData;
pBarCodeData = BarCode->GetBarCodeDataItem(0);
nTotalCount = pBarCodeData->nTotalCount;
pbVisited = (L_BOOL *)malloc(nTotalCount*sizeof(L_BOOL));
memset(pbVisited, 0, nTotalCount*sizeof(L_BOOL));
nCount = 0;
for (i = 0; i< nTotalCount; i++)
{
if(pbVisited[i])
continue;
pbVisited[i] = TRUE;
nCount++;
j = i;
pBarCodeData = BarCode->GetBarCodeDataItem(j);
while(pBarCodeData->nIndexDuplicate != -1 &&
pBarCodeData->nIndexDuplicate != 255)
{
j = pBarCodeData->nIndexDuplicate;
pBarCodeData = BarCode->GetBarCodeDataItem(j);
pbVisited[j] = TRUE;
}
}
free(pbVisited);
return nCount;
}
For example, in an array of ten barcodes, the first, third, and fifth might be duplicates of each other, while the 4th, 8th and 9th are duplicates of a different barcode. After this code is executed, nCount will contain the number of different sets of barcodes.
Required DLLs and Libraries
For complete sample code, refer to the BarCode demo. For an example, refer to LBarCode::GetFirstDuplicated.