I have followig task:
I am generating sequence of consecutive barcodes eg: 117-1, 117-2, 117-3, 117-4...
I have to print labels with those barcodes: first label with first code, second label with second code and so on.
Currently I am printig labels one-by-one. Is it possible in ZPL to combine multiple labels to one command for printer? Something like:
^header
print first one
take next label
print second one
take next label
...
^footer
I am generating ZPL so there is no need to introduce variables in ZPL.
My current code for printing single label
string zpl = string.Format(
#"^XA
^LH5,5
^CF0,129
^FO20,10
^FB800,4,,C
^FD{0}
^FS
^FO160,150
^FB800,1,,C
^BY3
^BCN,150,N,N,N
^FD{0}
^FS
^XZ
", code.ToString());
You can concatenate ZPL files to merge several labels into one.
Untested code would be something like this, if I understand your requirements:
String template = "^XA^LH5,5^CF0,129^FO20,10^FB800,4,,C^FD{0}^FS^FO160,150^FB800,1,,C^BY3^BCN,150,N,N,N^FD{0}^FS^XZ";
String zpl = String.format(template, code.toString());
zpl += String.format(template, code2.toString());
...and so one, or use a loop
Related
I have used GetText on an area of screen text and it has returned values separated by "\n". This is perfectly fine as there are line-breaks in the text and actually is exactly what I wanted, however, I want to convert the string into a list, splitting on the "\n".
My issue is that I get the following error from this line of foce:
put text split by "\\n" into itemList
Sensetalk compiler exception: syntax error - cant understand "n" at line.....
I initially thought there was a delimiting issue, having originally tried to split on "\n" so I switched to "\n" but the same error occurs..
How can you use the split function when there are escape sequences in the string?
many thanks
Depending on how OCR is reading this in, one of the predefined variables should be equivalent to your \n. I would expect this to work:
put text split by newline into itemList
You can find out more about predefined variables in SenseTalk here: https://docs.eggplantsoftware.com/studio/stk-restricted-words/#predefined-variables
I am using ZPL for the first time to generate shipping labels. I am using a ruby-on-rails gem https://github.com/rjocoleman/labelary to ultimately turn the ZPL sting into a pdf. I want to create multiple pages, incrementing a variable for each page using a loop until enough pages have been created. Say the ZPL looks like this:
^XA
^FX Top section with company logo, name and address.
^CF0,60
^FO50,50^GB100,100,100^FS
^FO75,75^FR^GB100,100,100^FS
^FO88,88^GB50,50,50^FS
^FO220,50^FDInternational Shipping, Inc.^FS
^CF0,40
^FO220,100^FD1000 Shipping Lane^FS
^FO220,135^FDShelbyville TN 38102^FS
^FO220,170^FDUnited States (USA)^FS
^FO50,250^GB700,1,3^FS
^FX Second section with recipient address and permit information.
^CFA,30
^FO50,300^FDJohn Doe^FS
^FO50,340^FD100 Main Street^FS
^FO50,380^FDSpringfield TN 39021^FS
^FO50,420^FDUnited States (USA)^FS
^CFA,15
^FO600,300^GB150,150,3^FS
^FO638,340^FDPermit^FS
^FO638,390^FD123456^FS
^FO50,500^GB700,1,3^FS
^FX Third section with barcode.
^BY5,2,270
^FO175,550^BC^FD1234567890^FS
^FX Fourth section (the two boxes on the bottom).
^FO50,900^GB700,250,3^FS
^FO400,900^GB1,250,3^FS
^CF0,40
^FO100,960^FDShipping Ctr. X34B-1^FS
^FO100,1010^FDREF1 F00B47^FS
^FO100,1060^FDREF2 BL4H8^FS
^CF0,190
^FO485,965^FDCA^FS
^XZ
How can I add a page break to the end of the ZPL string, so the loop can create a new identical page after the first one (all in a single zpl string)?
Thanks in advance
If your pages are truly identical, you could just use the ^PQ command to set the number of copies you want to print (e.g. ^PQ3 to print three copies). This command must appear before the ^XZ command.
However if your pages aren't identical (maybe you have a sequence number or something), just start a new format by using a new ^XA command after your first page is done.
I have been trying to print Group Separators using ZPL, but I can't seem to find a way to do that...
I have tried:
Copy and paste Group Separator directly in ZPL
Insert Hex of Group Separator (_1D) in ZPL
ZPL Code to reproduce the problem:
^XA
^FO100,100^BQN,2,6
^FH^FDA,GS--_1d^FS
^XZ
Online ZPL Emulator Result
It prints a QR-Code, however, we get the following string when we scan the QR-Code:
GS-IJ-IJ
It seems like ZPL converts Group Separators into "IJ". I have no idea why this is happening, does anyone know how we can do this?
Thanks in advance.
It turned out that this was a problem of the emulator.
When I printed the label using an actual ZPL printer, the code above correctly create QR Code with Group Separators inside.
What syntax do I use to print "hello world" in the output window?
I simply want to specify the text in the syntax and have it appear in the output.
You need the title command:
title 'this is my text'.
Note that the title can be up to 256 bytes long.
Alternatively, you could use ECHO also. ECHO is useful for debugging macro variable assignements where as TITLE is useful for neat/organised presentation of your tables with intension to perhaps export output results.
If you want to write arbitrary text in its own block in the Viewer rather than having it stuck in a log block, use the TEXT extension command (Utilities > Create text output). You can even include html markup in the text.
If you don't have this extension installed, you can install it from the Utilities menu in Statistics 22 or 23 or the Extensions menu in V24.
example:
TEXT "The following output is very important!"
/OUTLINE HEADING="Comment" TITLE="Comment".
Outfile here is used in an ambiguous way. The prior two answers (the TITLE and ECHO commands) simply print something to the output window. One additional way to print to the output window is the PRINT command.
DATA LIST FREE / X.
BEGIN DATA
1
2
END DATA.
PRINT /'Hello World'.
EXECUTE.
If you do that set of syntax you will actually see that 'Hello World' is printed twice -- one for each record in the dataset. So one way to only print one line is to wrap it in a DO IF statement and only select the first row of data.
DO IF $casenum=1.
PRINT /'Hello World'.
END IF.
EXECUTE.
Now how is this any different than the prior two commands? Besides aesthetic looks in the output window, PRINT allows you to save an actual text file of the results via the OUTFILE parameter, which is something neither of the prior two commands allows.
DO IF $casenum=1.
PRINT OUTFILE='C:\Users\Your Name\Desktop\Hello.txt' /'Hello World'.
END IF.
EXECUTE.
I'm currently trying to write a script which would run through a word document and output to a text file all the lines that are written in a certain font.
So if I had the document:
"This is the first line of the document.
This is the second line of the document.
This is the third line of the document."
And say normal lines are Times New Roman, bold is Arial, and italics is Sans Serif.
Then, ideally, I could parse the document for all lines in Arial and the text file output would have the line:
This is the second line of the document.
Any idea on how to do this from a script? I was thinking about first converting the doc into xml, but I do not think this is possible within a script.
You'll want to use the FIND object, and the FONT property of the FIND object.
So, something like this:
Public Sub FindTest()
Dim r As Range
Set r = ActiveDocument.Content
With r.Find
.ClearFormatting
.Style = "SomeStyleName"
Do While .Execute(Forward:=True, Format:=True) = True
'---- we found a range
Dim duperange As Range
Set duperange = r.Duplicate
Debug.Print r.Text
Loop
End With
End Sub
Note that where I've specified Style, you could specify font formatting via the FIND.FONT object, or various other formatting options. Just browse around the FIND object to see what's available.