I am writing a Delphi application that can read different barcodes, to enter data into different fields on the same form/page.
Because the same "id" can be used for multiple items (e.g. id 12开发者_JAVA技巧3 could be for parts, material, employee, etc), I need to find a way to:
- Incorporate the appropriate tag/field into the barcode itself, in any format (e.g. userid=123 or partid=123),
- parse this barcode info into a relevant field/value pair in order to insert the data in the right application textbox/select/radio button/etc.
It's similar to the pairs used in the web URLs where the parser splits pairs into field-value.
Best Regards,
The "barcode" is mostly irrelevant. You want to pack a name=value pair into as little space as possible, and later separate the "name" and "value" parts. The "barcode" part is only relevant because it imposes some limitations. Example: Depending on the kind of barcode you use, you may only use digits, and not too many of them. So you can't use an "=" sign.
Here's one possible implementation: Assign numbers to all your "names"; Let's say "part number" is 1, "material" is 2, "employee" is 3. Simply prefix the text you put into the barcode with the number!
Encoding is done like this:
Barcode.code := '1' + PartNumber;
Barcode.code := '2' + MaterialNumber;
Decoding is just as easy:
case BarcodeText[1] of
'1': PartNumber := Copy(BarcodeText,2,MaxInt);
'2': MaterialNumber := Copy(BarcodeText,2,MaxInt);
end;
精彩评论