0

Realizing that I should be using Line Print mode (as opposed to label mode) for sending CPCL to the Zebra QL 220 belt printer, I'm in the process of refactoring my working code (Why does everything print on the same line, even though I'm adding crlfs?) to this:

serialPort.Write("! 0 200 200 210 1\r\n"); 

serialPort.Write(string.Format("! U1 setvar {0} {1}", "device.languages", "line_print"));
serialPort.Write("Hallo die Welt\r\n\r\n"); //Bonjour le Monde --- Hola el Mundo --- Hallo die Welt

serialPort.Write("BARCODE-TEXT 7 0 5\r\n"); 
serialPort.Write(string.Format("BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("POSTFEED 120\r\n"); // empirical observation shows 120 is about the right amount of extra tape to expel after printing
serialPort.Write("PRINT\r\n");

This prints the barcode and its human-readable number beneath it (the value in "barcode"),but the text "Hallo die Welt" is not printed. Why not? Do I need a call to Print after each line, or...???

UPDATE

It still prints the barcode only (not "Hallo die Welt") with this code:

serialPort.Write("! 0 200 200 210 1\r\n");
serialPort.Write("! U1 SETLP 7 0 24\r\n"); 
serialPort.Write("Hallo die Welt\r\n\r\n"); 
serialPort.Write("BARCODE-TEXT 7 0 5\r\n"); 
serialPort.Write(string.Format("BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("POSTFEED 120\r\n");
serialPort.Write("PRINT\r\n");

UPDATE 2

This works (label mode):

serialPort.Write("! 0 200 200 210 1\r\n");
serialPort.Write("TEXT 4 0 30 40 Hallo die Welt\r\n\r\n"); //Bonjour le Monde --- Hola el Mundo --- Hallo die Welt
serialPort.Write("BARCODE-TEXT 7 0 5\r\n"); 
serialPort.Write(string.Format("BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("POSTFEED 120\r\n"); 
serialPort.Write("PRINT\r\n");

It prints:

~~~~~~~~~~~~~~~~~~~~~~~
Hallo die Welt

<barcode as a barcode>
<barcode as a number>
~~~~~~~~~~~~~~~~~~~~~~~

...but this doesn't work (line print mode):

serialPort.Write(string.Format("! U1 setvar {0} {1}", "device.languages", "line_print"));
serialPort.Write("! U1 SETLP 7 0 24\r\n");
serialPort.Write("Hallo die Welt\r\n\r\n");
serialPort.Write("! U1 BARCODE-TEXT 7 0 5\r\n");
serialPort.Write(string.Format("! U1 BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("! U1 SETLP 5 2 46"); 
serialPort.Write(barcode);
serialPort.Write("! U1 PRINT\r\n");

The problem is, I need to use Line Print mode.

Community
  • 1
  • 1
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

1 Answers1

1

You also need a \r\n after every SGD command (your setvar in this case)

It should be

! U1 setvar "device.languages" "line_print"\r\n

You also need to put the double quotes around the 2 parameters of the SETVAR command.

UPDATE:

oh, btw, just because the printer is in line_print mode, doesn't mean that it doesn't understand CPCL code. So the code above in your example is CPCL code, not just line print. If you put TEXT in front, it should work

Ovi Tisler
  • 6,425
  • 3
  • 38
  • 63
  • ? I do have double quotes around "device.languages" and "line_print". I had to make them args to string.Format() as I would otherwise be embedding double quotes within double quotes, which causes the compiler to throw it's hands into the air. I've added an update above. – B. Clay Shannon-B. Crow Raven Feb 11 '13 at 19:16
  • you can always escape the double quote with a backslash (e.g. "\"line_print\"" )... It still doesn't work even with the \r\n after the SGD? Try removing that line completely. You only need to set it once anyway – Ovi Tisler Feb 11 '13 at 20:11
  • What's SGD? Schlitz Genuine Draft? Unfortunately, I don't think that would help, either. – B. Clay Shannon-B. Crow Raven Feb 11 '13 at 21:19
  • Trying to escape the quotes as you show, I came up with: serialPort.Write("! U1 setvar "\"device.languages\"" "\"line_print\"" \r\n); ...but I get ") expected" on the first backslash (and then several more err msgs after that) – B. Clay Shannon-B. Crow Raven Feb 11 '13 at 21:26