Modify ZPL File

Hi there,

I need to find a solution for NAV 5.0 (so no fancy DOTNET stuff possible). I need to modify a ZPL file and add a new line at the very beginning of the document. In standard it is possible to write into a document at the end of the document, which works fine (but it's not what i need). Even if I set the pointer to the first char in the text file it will just overwrite any following characters - so that's not possible either. Here's the working solution:

IF LabelFile2.OPEN(DecompressedFilePath) THEN BEGIN
  LabelFile2.CREATEINSTREAM(StreamIn);
  FirstRow := 'This needs to be the first line';
  BigString.ADDTEXT(FirstRow);
  BigString.ADDTEXT(CRLF);

  WHILE NOT StreamIn.EOS DO BEGIN
    StreamIn.READTEXT(TextLine);
    BigString.ADDTEXT(TextLine);
    BigString.ADDTEXT(CRLF);
  END;

  IF LabelFile2.CREATE('\\PRINTFILES\' + 'test'+ '.zpl') THEN BEGIN
    LabelFile2.CREATEOUTSTREAM(StreamOut);
    BigString.WRITE(StreamOut);
    LabelFile2.CLOSE;
  END ELSE BEGIN
    ERROR('Error!');
  END;
END ELSE BEGIN
   ERROR('Cannot open Labelfile');
END;


That does everything I need. However, the ZPL printer is so picky when it comes to the format (e.g. many empty lines) of that file it doesn't print it, even if it's a legit ZPL file.

Do you know any other way to modify an existing file and just add a first line to it? If not: Maybe someone will run into that problem some day and hopefully my code above is of any help :)

Thanks a lot,
-S

Best Answer

  • HarakiriHarakiri Posts: 5
    Accepted Answer
    I actually fixed it. I was using CRLF for a new line. (Chars = CR := 10 and LF := 13). I just stripped out LF (Line Feed). That's it. Problem solved.

Answers

  • HarakiriHarakiri Posts: 5Member
    Accepted Answer
    I actually fixed it. I was using CRLF for a new line. (Chars = CR := 10 and LF := 13). I just stripped out LF (Line Feed). That's it. Problem solved.
Sign In or Register to comment.