LBarCode::IsDuplicated
#include "ltwrappr.h"
L_BOOL LBarCode::IsDuplicated (nIndex)
L_INT nIndex; |
/* index value */ |
Returns a value that indicates whether the specified barcode is duplicated or not.
Parameter |
Description |
nIndex |
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. |
Returns
TRUE |
The specified barcode is duplicated. |
FALSE |
The specified barcode is not duplicated. |
Comments
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 bar codes 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
LTBAR For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
See Also
Functions: |
LBarCode::LBarCode, LBarCode::Read, LBarCode::GetBarCodeDataItem, LBarCode::GetDuplicatedCount, LBarCode::GetFirstDuplicated, LBarCode::GetNextDuplicated, Class Members |
Topics: |
Example
For complete sample code, refer to the BarCode demo.
For an example, refer to LBarCode::GetFirstDuplicated().