Writing a Page Break to a Text File

lgplgp Member Posts: 77
edited 2011-05-05 in Navision Financials
Hi,
I am writing a text file for invoices. The customer prints the text file using Edit (DOS) on a continuous feed preprinted form. Right now, I have the alignment working for one invoice or several by sending extra blank lines to the file in the footer of the report:
For example:
FooterLine62:=' ';
APFile.WRITE(FooterLine62);

This works, but a blank page is printed at the end. If I remove one of the extra lines, the blank page does not print, but the alignment of the invoices is thrown off, so that the first page prints fine, but subsequent pages print too high.

So, I think I need to write a page break so that the printer knows to advance to the next page without printing a blank page at the end. I found information on page break characters (ff,ch(13),^L) but I don't know the syntax to write these to the file. If I use the above code:

FooterLine62:=ff;
APFile.WRITE(FooterLine62);

this results in an error. I have tried putting quotes around the ff, brackets, everything I could think of, but NAV gives an error unless I use the single quote around the characters, then it prints it as literal text in the file.

Any suggestions? ](*,)
Thanks in advance...
Leanne G. Paul
Business Applications/IT Advisor, Competitive Edge Services

Comments

  • jglathejglathe Member Posts: 639
    Hi lgp,

    try this:

    define a character variable

    MyChar char

    assign the value you want by direct assignment of the integer value:

    MyChar := 255;

    write this to your file:

    APFile.write(MyChar);

    The file should be in binary mode for this, otherwise the application adds a CR/LF on the end. Which you can circumvent by using APFile.pos.

    with best regards and HTH

    Jens
  • lgplgp Member Posts: 77
    Thank you for the response Jens...
    I got the page break into the file using the method you described. However, if I do it with the file in binary mode, the file doesn't write the text properly. If I do it with the file in ASCII mode, I get extra pages printing in between invoices. I guess that is because of the CR/LF on the end. I looked up the "POS" command that you mentioned, but I'm not sure how I would use that to deal with the extra pages. Would that be in conjunction with the TRUNC command?
    Leanne G. Paul
    Business Applications/IT Advisor, Competitive Edge Services
  • jglathejglathe Member Posts: 639
    Hi lgp,

    the POS command only adjusts the file pointer. After writing the page break, something like

    file.pos(file.len-2);

    adjusts the pointer for the next write operation. If it's the last page, an additional file.trunc would truncate the file to this position. Since you write the file sequentially, a pos/trunc combination after every page break won't hurt.

    with best regards

    Jens
  • lgplgp Member Posts: 77
    position:=APFile.POS;
    APFile.SEEK(position-2);
    =D>
    Works beautifully - except for the last page. A page break is also inserted on the last page, so I still get the extra page at the end. I need to figure out how to say "only write the page break on pages that are not the last page"...

    Back to work!
    Thanks again for the help!
    Leanne G. Paul
    Business Applications/IT Advisor, Competitive Edge Services
  • SavatageSavatage Member Posts: 7,142
    Your not the first or probably the last to struggle with dot matrix printer ](*,)
Sign In or Register to comment.