B4J Question [Solved] Problem generating Code39 barcodes (Erel’s PyBridge example)

BlueVision

Well-Known Member
Licensed User
Longtime User
This question relates to an issue with the implementation of Erel’s [PyBridge] ‘Create barcodes’ thread.
For compatibility reasons, I am obliged to generate a Code39 barcode. Following Erel’s instructions, I was able to integrate his code into my programme via PyBridge (and was very grateful not to have to ‘reinvent the wheel’).
However:
I’m not sure whether my problem stems from an error in my implementation or whether the issue lies with the Python library I’m using.
The generated barcode always contains an additional character at the end of the string I have specified (in the field outlined in red). This character is always the same, regardless of the string used in the field. Could this perhaps be the checksum that is included in the barcode? The description of the Python library states the following:
Description of Code39:
class barcode.codex.Code39(code: str, writer=None, add_checksum: bool = True)
A Code39 barcode implementation
Parameters:  
code – Code39 string without * and without checksum.
writer – A barcode.writer instance used to render the barcode (default: SVGWriter).
add_checksum – Add the checksum to code or not
If that is the case, could someone help me figure out how to pass the relevant parameter as ‘false’ to the Python code? To be honest, I’m a bit at a loss with this at the moment. How do I display the result without a checksum?
The image on the left shows a Code39 barcode with the problem, the image on the right shows a Code128 barcode. This one has no checksum and is correct, but unfortunately I cannot use it.
Thanks in advance to everyone who might look into my problem and perhaps even find a solution.

BV

1792357694009.png
1792358910832.png
 
Last edited:
Solution
Change
B4X:
EAN.Call.Arg(Code).ArgNamed("writer", ImageWriter.Call).Run("write").Arg(rv)
to
B4X:
EAN.Call.Arg(Code).ArgNamed("add_checksum", False).ArgNamed("writer", ImageWriter.Call).Run("write").Arg(rv)

teddybear

Well-Known Member
Licensed User
Change
B4X:
EAN.Call.Arg(Code).ArgNamed("writer", ImageWriter.Call).Run("write").Arg(rv)
to
B4X:
EAN.Call.Arg(Code).ArgNamed("add_checksum", False).ArgNamed("writer", ImageWriter.Call).Run("write").Arg(rv)
 
Upvote 1
Solution

BlueVision

Well-Known Member
Licensed User
Longtime User
Teddybear, you’ve saved my day. As suspected, the character at the end of the generated code was the checksum. I’d already been experimenting with the parameter (“add_checksum”), but my syntax was definitely incorrect, unlike your line of code. I hadn’t thought of moving this parameter to the start of the command, though. In this case, the IDE doesn’t necessarily flag incorrect syntax as an error. It’s just that the code doesn’t work at runtime. You can’t have everything.
Thanks!
 
Upvote 0
Top