Printer.Write NO longer works with Byte Array in RAW mode (Lazarus 1.6, FPC 3.0) lazarus / 31-LCL ---------------------------------------------------------------------- gabriemarcelo · 2016-12-28 10:29 Hi guys, I used to have the following code working fine with older versions of both Lazarus and FPC but with Lazarus 1.6 and FPC 3.0 I cannot get it working! The code is very simple. I'm trying to print an array of bytes to a printer in raw mode (a Zebra printer). If I call Printer.Write passing a string, it works just fine BUT if I use the overload function which takes an array, it does not work!!! Even the Written var is set to 3 (which is expected as I'm passing 3 bytes in the array) after executing the last line but it does not print anything!!! Any hints please???? Here's my test code. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var   Written: Integer;   arrData: array of byte;begin    showmessage('Printing RAW string');    Printer.RawMode := true;   Printer.BeginDoc;   Printer.Write('~WC'); //Command for printing a config label   Printer.EndDoc;    showmessage('Printing RAW bytes');    SetLength(arrData, 3);   arrData[0] := 126; //~   arrData[1] := 87;  //W   arrData[2] := 67;  //C    Printer.RawMode := true;   Printer.BeginDoc;   Printer.Write(arrData, Length(arrData), Written);   Printer.EndDoc; end; ---------------------------------------------------------------------- gabriemarcelo · 2016-12-28 12:00 I had to create a RawByteString and create it by using the byte array to finally use the Printer.Write that takes an asnistring as param to get it working. WHY the Printer.Write function that takes a byte array is not working??? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var   Written: Integer;   arrData: array of byte;   sData : RawByteString;begin    showmessage('Printing RAW bytes');    SetLength(arrData, 3);   arrData[0] := 126; //~   arrData[1] := 87;  //W   arrData[2] := 67;  //C    SetString(sData, PAnsiChar(pointer(arrData)), length(arrData));    Printer.RawMode := true;   Printer.BeginDoc;   //Printer.Write(arrData, Length(arrData), Written);   Printer.Write(sData);   Printer.EndDoc;           end; ---------------------------------------------------------------------- ttomas · 2016-12-28 14:36 Do you try with Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    SetLength(arrData, 4);   arrData[0] := 126; //~   arrData[1] := 87;  //W   arrData[2] := 67;  //C   arrData[3] := 0;  // PAnsiChar have #0 null terminated ---------------------------------------------------------------------- marcov · 2016-12-28 14:49 Quote from: gabriemarcelo on December 28, 2016, 11:29:25 amI used to have the following code working fine with older versions of both Lazarus and FPC but with Lazarus 1.6 and FPC 3.0 I cannot get it working! Did you change a static array to a dynamic array? I'd expect that this would never work in any version, but it would work with a static array. Try Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    Printer.Write(arrData[0], Length(arrData), Written);  ; notice the ---------------------------------------------------------------------- gabriemarcelo · 2016-12-28 15:59 Thanks marcov that did the trick!