Mixing LoadXMLSettings and property setting functions
Here are some handy tips for mixing LoadXMLSettings and property setting functions…
So what is LoadXMLSettings?
This is a function that allows you to load properties for the Softek Barcode Reader Toolkit from an XML file (or string in XML format). One special feature of this allows you to load multiple sets of properties that the toolkit will use successively until it finds a barcode.
For example, say you want to try scanning first without a median filter and then with a median filter, your file might look like:
<xml version=’1.0′ encoding=’iso-8859-1′>
<SoftekBarcode>
<Properties>
<MedianFilter>0</MedianFilter>
</Properties>
<Properties>
<MedianFilter>1</MedianFilter>
</Properties>
</SoftekBarcode>
</xml>
So what happens if you also set some properties using functions such as SetPageNo?
The answer is it all depends on the order…
If you do:
barcode.LoadXMLSettings(xmlFileToLoad)
barcode.SetPageNo = pageNumberToScan
Then it will first try scanning with PageNo = pageNumberToScan and MedianFilter = 0. If that fails to find a barcode it will then apply the second property set, which will be PageNo = 0 and MedianFilter = 1.
Note that PageNo is actually set to 0. This is because the property values in everything but the first property set were fixed when LoadXMLSettings was called.
The correct way to mix the calls is:
barcode.SetPageNo = pageNumberToScan
barcode.LoadXMLSettings(xmlFileToLoad)
Doing it this way ensures that PageNo is set to the correct value in all property sets in the XML file.