Is it possible to add printer commands to a field? Follow

0
Avatar
Jim Mason

I have to embed a serialisation number along with other data in a Code128 barcode and also display that number in a separate text field. I need to use the printer to increment the numbers but bartender insists on sending down 9999 individual labels. I know I have bartender options set correctly as I can remove the barcode and print with just the text field. This sends just one label design that the printer can print multiple copies and the printer increments as each label is printed. I can also have the printer increment correctly if I remove the serialisation from within the barcode, using fixed data only.

I know from sending a label design from old VB3 code that I can send  the barcode field information to my printer. If I add a carriage return then '+01' to the field string the printer will then increment both the barcode and text locally.

Is there any way in vbscript that I can get access to this low-level field information for the barcode, add my CR+01 to it and continue the print? Note it's no use adding it to the label field as before it goes to the printer it is formatted with printer font info, position on label etc. It needs to be added just before the final formatted strings are sent to the printer.

5 comments

0
Avatar
Shotaro Ito
Comment actions Permalink

What printer do you use?
When you use printer driver by Seagull, and the printer supports serialization on Code128 barcode,
You can create a print job to specify multiple serialized copies to save print job size.

There's some conditions to make device serialization.

  1. In BarTender print dialog, Performance tab, enable [Allow serialization]
  2. Variable text (Serial number) must be Device font (ex: Zebra Triumvirate, Datamax Font 1 etc.)
  3. No VB script is used in serialized data source
  4. Media handling (ex: Auto cutter per database record etc) not set (Use driver's settings)
  5. No other template inserted in Page setup > Templates

There could be more reason  - please check white paper below.
https://www.seagullscientific.com/media/101561/optimizing-print-output-201511.pdf

Another option is Print Code Modifier.
You can modify print code generated by BarTender + Driver, before sent to printer.
From file > BarTender document options > General tab. VScript Sample is below.
http://help.seagullscientific.com/2016/en/Index.htm#vbs_PCM.htm
Personally I don't recommend this approach for serialization though.

In both cases, when you enable [Print To file] tick on Print dialog, you can save print code to file instead of sending printer.
(Print to file option is not available in Trial edition.)

0
Avatar
Jim Mason
Comment actions Permalink

Thank you Shotaro Ito, the print code modifier example is exactly what I need. I've tried the other methods which generally work until you link a database to the label, when they do not. Tech support are working on this at the moment.

0
Avatar
Jim Mason
Comment actions Permalink

Update to this, as I've got font information which is binary I need to use the ReadBytes and Writebytes method for matching strings. I've never used these before and I can't get my head around the use of them. I can read a byte and write it back, that all works fine, but how do I compare a byte? I've tried everything I can think of but always get a type mismatch error. Any help gratefully received.

 

Option Explicit

Dim byteBuf(1)
Dim first_byte,second_byte,third_byte,fourth_byte,dummy
Dim value_write


while not PCM.FileAtEOF
dummy=PCM.ReadBytes(byteBuf, 1)
first_byte=byteBuf
value_write=PCM.WriteBytes(byteBuf, 1)
dummy=PCM.ReadBytes(byteBuf, 1)
second_byte=byteBuf
value_write=PCM.WriteBytes(byteBuf, 1)
dummy=PCM.ReadBytes(byteBuf, 1)
third_byte=byteBuf
value_write=PCM.WriteBytes(byteBuf, 1)
dummy=PCM.ReadBytes(byteBuf, 1)
fourth_byte=byteBuf
value_write=PCM.WriteBytes(byteBuf, 1)

wend


'I need to compare first_byte with '3', Ascii 51


if first_byte=???? then '(whatever I put here,51, chr(51), asc("1") i get type mismatch)

'actions here on a match

end if

0
Avatar
Shotaro Ito
Comment actions Permalink

Hmm. Handling binary in PCM is actually difficult.
Simple binary code sample is below but that doesn't explain how to compare binary sequence.

Option Explicit

Dim byteBuf()
Dim codeSize, numRead, numWritten

codeSize = PCM.InputFileSize
numRead    = 0
numWritten = 0

ReDim byteBuf(codeSize)
numRead = PCM.ReadBytes(byteBuf, codeSize)
numWritten = PCM.WriteBytes(byteBuf, numRead)

Store codes to array of binary (which actually is 8bit int) so you can simply compare such as

If byteBuf(x) = 51

Or try below:

- Find out the reason why BarTender's serialize optimization not working. Note that GS1-128 serialization doesn't work on BT10.1 (which fixed in BT2016)

- Some driver allows to use text format for TrueType font / Image. Check Print dialog > Document Properties > Options tab etc.
Once you can rule out binary from print code, handling code is much easier.

0
Avatar
Jim Mason
Comment actions Permalink

Thanks Shotaro Ito, that did it. I needed to use first_byte=byteBuf(0), I didn't realise it is an array of one byte!

Please sign in to leave a comment.