• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Barcode 128B problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Barcode 128B problem


  • Subject: Barcode 128B problem
  • From: Brian Christmas <email@hidden>
  • Date: Thu, 18 Feb 2016 20:59:44 +1100

G’day scripters

I’m trying to write a handler that will print readable barcodes in the 128 type B format, but I keep finding my scanner won’t read my printouts, even in large font sizes. The scanner checks out OK with test prints from the font site.

I think I’ve got the code right, but would appreciate anyone with expertise in barcodes to check it, please.

I’m using the free Barcode128 font, available from here.

My code is below.

TIA, and good luck with it.

Regards

Santa

tell application "TextEdit"
activate
tell application "System Events" to tell process "TextEdit"
keystroke "n" using command down
end tell
set theText to "Test of Code128. "
set theTextInsert to ""


set FontSize to 30
set the clipboard to "Font Size is " & FontSize as text
tell application "System Events" to tell process "TextEdit"
keystroke "v" using command down
end tell
tell front document
set the font of last paragraph of its text to "Times"
set the size of last paragraph of its text to 12
end tell
end tell
repeat with y from 0 to 6
set x to y / 2
set theTextInsert to theTextInsert & " " & y as text
set theBarCodeTextModulus to my setUpTextCount(theText & theTextInsert as text)
#
# For barcode128 type B, the start character is 'Ì'
set theBarCodePrintText to ("Ì" & theText & theTextInsert & (ASCII character (theBarCodeTextModulus)) & "Î" as text)
tell application "TextEdit"
activate
set the clipboard to (return & " " & return as text)
tell application "System Events" to tell process "TextEdit"
keystroke "v" using command down
end tell
tell front document
set the font of last paragraph of its text to "Times"
set the size of last paragraph of its text to 6
end tell
delay 0.1
set the clipboard to ("Text Length is " & (count of (theBarCodePrintText as text)) + 2 & return as text)
tell application "System Events" to tell process "TextEdit"
keystroke "v" using command down
end tell
tell front document
set the font of last paragraph of its text to "Times"
set the size of last paragraph of its text to 12
end tell
set the clipboard to (return & " " & return as text)
tell application "System Events" to tell process "TextEdit"
keystroke "v" using command down
end tell
tell front document
set the font of last paragraph of its text to "Times"
set the size of last paragraph of its text to 3
end tell
set the clipboard to (theBarCodePrintText as text)
tell application "System Events" to tell process "TextEdit"
keystroke "v" using command down
end tell
tell front document
set the font of last paragraph of its text to "Code128"
set the size of last paragraph of its text to FontSize
end tell
end tell
end repeat

on setUpTextCount(theText)
set eachCharacterCount to 0
repeat with x from 1 to count of theText
set eachCharacter to item x of theText
set eachCharacterCount to eachCharacterCount + (((ASCII number of eachCharacter) - 32) * x)
end repeat
set eachCharacterCount to eachCharacterCount + 104 # 104 is value of start character of Code 128 type B
set theModulusNumber to eachCharacterCount - (103 * (eachCharacterCount div 103))
# say theModulusNumber
return theModulusNumber
end setUpTextCount

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Problem saving a message in Outlook 2011
      • From: Dave <email@hidden>
    • Problem saving a message in Outlook 2011
      • From: Dave <email@hidden>
  • Prev by Date: Re: How to make a window Front in MS Outlook 2011
  • Next by Date: Re: How to make a window Front in MS Outlook 2011
  • Previous by thread: Re: How to make a window Front in MS Outlook 2011
  • Next by thread: Problem saving a message in Outlook 2011
  • Index(es):
    • Date
    • Thread