Thank you.
tell application "TextEdit"
activate
tell application "System Events" to tell process "TextEdit"
keystroke "n" using command down
end tell
end tell
set theText to "This is barcode 128. "
repeat with x from 1 to 10
set theText to (theText & " " & x as text)
set theModulusCharacter to (my setUpTextCount(theText))
set theBarCodeText to theText & (character id theModulusCharacter)
delay 0.1
set the clipboard to ((character id 209) & theBarCodeText & (character id 211) as text)
tell application "TextEdit"
activate
tell front document
tell application "System Events" to tell process "TextEdit"
keystroke "v" using command down
end tell
set the font of last paragraph of its text to "Code 128"
set the size of last paragraph of its text to 36 #
end tell
set the clipboard to (return & return as text)
tell front document
tell application "System Events" to tell process "TextEdit"
keystroke "v" using command down
end tell
end tell
end tell
end repeat
on setUpTextCount(theText)
set eachCharacterCount to 104 # the value of the start character for Barcode 128 Set B
repeat with x from 1 to count of theText # We start counting from the first character of the actual text,and multiply it’s adjusted value by its position
set eachCharacter to item x of theText
set eachCharacterAscii to (id of eachCharacter)
if eachCharacterAscii < 127 then
set subtractAsciiOffset to 32
else
set subtractAsciiOffset to 105
end if
set eachCharacterCount to eachCharacterCount + ((eachCharacterAscii - subtractAsciiOffset) * x)
end repeat
set theModulusNumber to eachCharacterCount mod 103
set theAddOnAscii to 32
# This commented out line uses 105 as the Font example shows, and thanks to Steve Mills, it now WORKS!
if theModulusNumber > 94 then set theAddOnAscii to 105
return theModulusNumber + theAddOnAscii
end setUpTextCount