Writing a Page Break to a Text File

lgp
Member Posts: 77
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...
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
Business Applications/IT Advisor, Competitive Edge Services
0
Comments
-
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
Jens0 -
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 Services0 -
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
Jens0 -
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 Services0 -
Your not the first or probably the last to struggle with dot matrix printer ](*,)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions