 |
|
|
 |
|
|
 |
|
 |
Would it be possible to call out the C# code in plain C language?
|
|
|
|
 |
|
 |
On the Build tab of your project Properties you will find the check box "Register for COM interop". Check it and rebuild your project. As a result you will be able to make calls from COM code (like C, VB6 etc).
|
|
|
|
 |
|
 |
How do you covert the encode bar to printed barcode image?
|
|
|
|
 |
|
 |
Hi,
i'm planning to do a project name library management system in which i hav to use barcodes . . . . .
i have to generate barcodes for student details and also for the bookdetails...
i'm new to this area of barcodes.can anyone pls tell me which type of barcode to use,which will be suitable and simple for this application...
i live in india..
pls help me..
|
|
|
|
 |
|
 |
The "buzzword" library points to Codabar symbology.
As alternatives you may use Code39 or even Code93 symbologies.
If students or book details have a significant capacity (more than few bytes), then you may consider using a 2D symbology like DataMatrix.
CodeProject has a variety of articles with source code for all the above symbologies.
|
|
|
|
 |
|
 |
I recently downloaded your source code and am attempting to compile it using VS2005, C#2.0, .Net2.0.
I am getting the error message, "Type expected" at line 46 of OneCode.cs
public static String OneCodeBars(this String source) {
Please correct this error and repost the solution at your convience.
Thank you and Happy New Year.
|
|
|
|
 |
|
 |
Actually there is no error. You probably missed the statement "The downloads include one VB.NET and one C# class – VS2008 with .NET 3.5 syntax - that generate..."
The error message is generated because of the var keyword (implicitly typed local variables) that is available only in C# 3.0.
In order to compile with C# 2.0 and VS2005 replace all vars with explicit types.
For example loops with integers will be:
for (Int32 i = 0...
instead of:
for (var i = 0...
Happy new year
|
|
|
|
 |
|
 |
One needs to get the USPS encoder and font for generating the Intelligent Mail Barcode.
Go to: http://ribbs.usps.gov/onecodesolution/
Request your username and password from usps. You should get it in a day.
Download: uspsEncoderMsWindows32-1.2.0.zip, USPS4CBFONTS.zip from the URL above.
Unzip and copy the encoder (uspsEncoderMsWindows32-1.2.0\modules\c\usps4cb.dll) to the Windows directory.
Copy the font (USPS4CBFONTS\nonAfpFontsv1r2m0\fonts\truetype) to the Windows\Fonts directory.
User guide is under the directory - uspsEncoderMsWindows32-1.2.0\userGuide\. Do the following to your .Net project.
Step 1: Use the USPS published encoder (Windows C dll) to encode the barcode string.
//Definition
[DllImport("usps4cb.dll", EntryPoint = "USPS4CB")]
public static extern int USPS4CB(
[MarshalAs(UnmanagedType.LPStr)] String TrackString,
[MarshalAs(UnmanagedType.LPStr)] String RouteString,
[MarshalAs(UnmanagedType.LPStr)] StringBuilder buf);
//declare variable to hold the encoded bar string
StringBuilder BarString = new StringBuilder(65); //keep to 65 since encoder returns //65 specific characters
//Sample Function Call
int RetCode = USPS4CB("01234567094987654321", "01234", BarString);
Step 2: Use the encoded string (BarString) from above to display the barcode using the font USPS4CB.
This way we can get both the return code and the encoded string. Happy Intelligent Mail Barcode programming.
Lakshmi Narayanan
Software Developer
|
|
|
|
 |
|
 |
Does anyone have a sample working version of this app in VB.net? If so can you send me the app in a zip file. thanks
|
|
|
|
 |
|
 |
I get a stack imbalance error when I use this. Any ideas?
Thanks,
Crobbins
|
|
|
|
 |
|
 |
Hi Crobbins, Had the same issue. I fixed it by changing the target framework from 4.0 to 3.5.
|
|
|
|
 |
|
 |
Step 2: Use the encoded string (BarString) from above to display the barcode using the font USPS4CB.
Can you explain how to implement step 2. I need to display the intelligent barcode on a form. thanks.
|
|
|
|
 |
|
 |
Hello All!
Let me start off by thanking drdigit for all of his hard work.
It truly is a quality application.
However, there is a bug or two in the decoder. I have tried both the C# and VB versions, with the same result.
The string that causes the problem is...
Encode:
"72 777 777777 777777777 77777777777" -> FFDTADTDAFTATDTTDDTFDTAAFAFDDTATTFTTAAAFFDFATATTAFTDFATDDDFTFFFDD
Decode:
"FFDTADTDAFTATDTTDDTFDTAAFAFDDTATTFTTAAAFFDFATATTAFTDFATDDDFTFFFDD" -> "17 777 777777 777777777 77777777777"
...but I would imagine the error would occur if the numbers were different. So far in testing, I am told the first digit cannot be over 4, otherwise an overflow occurs.
Please look into this drdigit as I will be releasing a converted PHP version in the coming weeks. At this point, it functions exactly like both the C# and VB versions (and returns the same overflow error).
|
|
|
|
 |
|
 |
I found some errors in the decode as well and was able to correct the error with a few lines of code.
And a few other small modifications.
|
|
|
|
 |
|
 |
Could you please post the few lines of code you changed?
When I decode:
FTTFTADTFATTDDDTDTDTTDDDDDDTADDFFTAADDTFATDFTTAADTAFDDFAAFFTADDFA
the USPS results are: 00700123456123456792605211234
but this decoder gives: 15814079586565956792604312759
which is obviously incorrect.
Thanks - Gylfi
|
|
|
|
 |
|
 |
One of the most important problems that I found was in the following code. Additions are remarked with my initials. 'bgh
I discovered that examples like the one you provided (FTTFTADTFATTDDDTDTDTTDDDDDDTADDFFTAADDTFATDFTTAADTAFDDFAAFFTADDFA) that would result in a -1 index value in the table 5of13 and in the table2of13, my code does a 3rd test of index <0 and sets test = not test and 8191 then rechecks the table2of13
For i = 0 To 9
Dim test = ad(i), index = Array.IndexOf(table5of13, test)
If (index < 0) Then
test = Not test And 8191
index = Array.IndexOf(table5of13, test)
If (index < 0) Then
test = ad(i) 'bgh
index = Array.IndexOf(table2of13, test)
If (index < 0) Then ' bgh
test = Not test And 8191 'bgh
index = Array.IndexOf(table2of13, test) 'bgh
End If 'bgh
index += 1287
End If
End If
ad(i) = index
Next
In the next section I made these changes.
'original code start
For i = 2 To 19
OneCodeMathAdd(byteArray, 13, -r)
OneCodeMathDivide(byteArray, 10)
r = OneCodeMathMod(byteArray, 10)
result = r.ToString() & result
Next
OneCodeMathAdd(byteArray, 13, -r)
OneCodeMathDivide(byteArray, 5)
r = OneCodeMathMod(byteArray, 5)
result = r.ToString() & result
OneCodeMathAdd(byteArray, 13, -r)
OneCodeMathDivide(byteArray, 10)
'original code end
' my code start
For i = 2 To 18 'bgh only loop 2 to 18 because the 19th test should be mod 5
OneCodeMathAdd(byteArray, 13, -r)
OneCodeMathDivide(byteArray, 10)
r = OneCodeMathMod(byteArray, 10)
result = r.ToString() & result
Next
OneCodeMathAdd(byteArray, 13, -r)'bgh
OneCodeMathDivide(byteArray, 10) 'bgh
r = OneCodeMathMod(byteArray, 5) 'bgh 19 divide by 10 is then mod 5
result = r.ToString() & result 'bgh
OneCodeMathAdd(byteArray, 13, -r) 'bgh
OneCodeMathDivide(byteArray, 5) ' bgh now divide by 5 and mod 10
r = OneCodeMathMod(byteArray, 10) 'bgh
result = r.ToString() & result ' bgh last result
OneCodeMathAdd(byteArray, 13, -r)' bgh
OneCodeMathDivide(byteArray, 10) 'one last divide by 10
'my code end
Those are the changes that I made to get the correct results that match the postal decoder.
my version of the decoder result =
00700123456123456792605211234
|
|
|
|
 |
|
 |
Was not sure how to post the code, so I hope it appears correctly in the previous message, found that html was botching some of my response so I reposted with corrections.
|
|
|
|
 |
|
 |
I wanted to make another comment about the first for next loop.
If at any time (index = -1) prior to the (index +=1287) it is a very good indication that the barcode being decoded is invalid.
If a value of -1 reaches that line of code the code will continue with a decode result, but the result really should be invalid.
If the index is still -1 with the code changes I made, then the test was not found in the table.
To test this, type in a random series of ATFD letters, and use the decode routine. There will be a result, but it would likely fail on the Postal decoder.
The correct place to test for an invalid code would be a result of -1 at this section...
If (index < 0) Then ' bgh
test = Not test And 8191 'bgh
index = Array.IndexOf(table2of13, test) 'bgh
End If 'bgh
insert
if index = -1 then
message box invalid code etc....
endif
index += 1287
|
|
|
|
 |
|
 |
Thanks a lot for posting these fixes - this is very helpful.
I inted to take the mailText.txt file that the USPS provides and run that through both the USPS decoder and this one and compare the results. If all of those barcodes yield the same results, then we're probably in good shape. I'll let you know.
Thanks again - Gylfi
|
|
|
|
 |
|
 |
Please let me know the results and where do I get this mailText.txt?
Gylfi Ingvason wrote:
I inted to take the mailText.txt file that the USPS provides and run that through both the USPS decoder and this one and compare the results.
|
|
|
|
 |
|
 |
The mailText.txt is available at the USPS IMB download site at:
https://ribbs.usps.gov/index.cfm?page=intellmailmailpieces
The file contains 1257 addresses and associated IMB barcodes that are broken down into into components for testing. After applying your fixes posted earlier, the decoding of all these barcodes match the results of the USPS decode web site. Nice job!
You have to sign up for a user-id/password to access the USPS site, and it took them a few weeks to issue mine if I remember correctly. It seems absurd that they don't just make this stuff public, but it's the government we're talking about, so who knows what the thinking is.
If you are interested, send me a private e-mail to
gylfi@computer.org
and I'll e-mail you the file. I don't think I'll be breaking any laws in doing so, but like I said, all of them match now. Thanks a bunch for taking the time to debug this - it surely is appreciated.
Best regards,
Gylfi
|
|
|
|
 |
|
 |
These changes are not reflected in either your VB or your C# code -- can you please make the changes & repost your source code? Also, please run the 4 samples from the USPS IMb Specification SPUSPSG - I'm experiencing progressive error as the DP ZIP content increases:
"01234567094987654321"
"0123456709498765432101234"
"01234567094987654321012345678"
"0123456709498765432101234567891"
This fixes the error:
For i = 0 To 9
Dim test = ad(i), index = Array.IndexOf(table5of13, test)
If (index < 0) Then
test = Not test And 8191
index = Array.IndexOf(table5of13, test)
If (index < 0) Then
test = ad(i) 'bgh
index = Array.IndexOf(table2of13, test)
If (index < 0) Then ' bgh
test = Not test And 8191 'bgh
index = Array.IndexOf(table2of13, test) 'bgh
End If 'bgh
index += 1287
End If
End If
ad(i) = index
Next
ad(9) = CType(ad(9) \ 2, Integer)
If (ad(0) > 658) Then ad(0) -= 659
OneCodeMathMultiply(byteArray, 13, 659) 'added missing multiply
OneCodeMathAdd(byteArray, 13, ad(0))
For i = 1 To 8
OneCodeMathMultiply(byteArray, 13, 1365)
OneCodeMathAdd(byteArray, 13, ad(i))
Next
OneCodeMathMultiply(byteArray, 13, 636)
OneCodeMathAdd(byteArray, 13, ad(9))
r = OneCodeMathMod(byteArray, 10)
result = r.ToString() & result
For i = 2 To 18 'bgh only loop 2 to 18 because the 19th test should be mod 5
OneCodeMathAdd(byteArray, 13, -r)
OneCodeMathDivide(byteArray, 10)
r = OneCodeMathMod(byteArray, 10)
result = r.ToString() & result
Next
OneCodeMathAdd(byteArray, 13, -r)'bgh
OneCodeMathDivide(byteArray, 10) 'bgh
r = OneCodeMathMod(byteArray, 5) 'bgh 19 divide by 10 is then mod 5
result = r.ToString() & result 'bgh
OneCodeMathAdd(byteArray, 13, -r) 'bgh
OneCodeMathDivide(byteArray, 5) ' bgh now divide by 5 and mod 10
r = OneCodeMathMod(byteArray, 10) 'bgh
result = r.ToString() & result ' bgh last result
OneCodeMathAdd(byteArray, 13, -r)' bgh
OneCodeMathDivide(byteArray, 10) 'one last divide by 10
' at this point all that remains is the encoded DP ZIP - convert to int and skip to the "if rest > 1000100001" section
I also have a JavaScript/JScript version validated against all USPS test cases.
modified on Thursday, November 4, 2010 1:12 AM
|
|
|
|
 |
|
 |
Are you saying that you still experience errors after you apply my fixes or that you would like drdigit to apply the fixes?
|
|
|
|
 |