Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to eject 'X' amount of lines before printing a report

Status
Not open for further replies.

foxprox558

Programmer
Oct 19, 2013
53
0
0
US
My program has a function allowing the user to set an eject line before print number, Currently I am using :
(Printer is already set based on user input in setup file)
nEj=printers.invpre && (Inventory Pre-Printing ejection)
for x=0 to nEj step 1
Set device to printer
?chr(13)
endfor
set device to screen
REPORT FORM cGen+"orderticket.frx" NOCONSOLE noeject preview
 
And that doesn't work?

How about using the EJECT command?

I have such an option in a report I use to print on label sheets, to be able to use sheets more than once, if not all labels are used. What do I do? I simply add a number of empty labels in front of the labels I want to print in the print cursor and then print.

How is your situation? This won't work in a report having a header. One thing you may be able to do is open the frx and manipulate it to have a larger top margin than normally. That would only be good for page1 though, or for a single page report, as that of course affects all pages.

Bye, Olaf.
 
eject line

EJECT a Line?
Or do you mean PRINT one or more Blank Line(s)?

If PRINT a Blank Line, then merely do as many APPEND BLANK as requested to your Report Data Cursor and have an Index which will put the Blank Lines at the top.

Code:
SELECT *;
 FROM RealData;
 WHERE [i]<Whatever Selection Criteria>[/i];
 INTO CURSOR ReportData READWRITE

IF nBlankLineCnt > 0 && nBlankLineCnt entered somewhere earlier by user
   SELECT ReportData
   FOR Cntr = 1 TO nBlankLineCnt  
     APPEND BLANK
   ENDFOR
ENDIF

SELECT ReportData
INDEX ON IIF(EMPTY([i]<some field name>[/i]),'1','2') TAG RptSort  && Or some other Index Expression
REPORT FORM cGen+"orderticket.frx" NOCONSOLE NOEJECT PREVIEW

Good Luck,
JRB-Bldr
 
I neglected to add - it also depends on how your Report Form is laid out.

As Olaf has pointed out: This won't work in a report having a header.
If you have a populated Header on you Report Form, then that approach probably would not work - since the Blank lines would appear in your Detail Band below your Header.

But if have No Header and only Detail Band(s) defined, it would work.

Good Luck,
JRB-Bldr
 
I'm also not clear whether you want to eject a given number of lines, or an entire page.

If you want some blank lines before the first line of the report, then your code won't do that. That's because the REPORT FORM command, by default, starts a new print job, and a new print job starts on a new page. The effect of your code will be to eject a blank page before printing the report, which I assume is not what you want.

The NOEJECT clause does not change that. In fact, NOEJECT does nothing. It is supported only for backward compatibility. You might be confusing it with NOPAGEEJECT, but that won't do what you want either. NOPAGEEJECT is only useful when you are printing multiple reports to the same print job; it inhibits the page eject after each report, not before it.

If you want blank lines to appear on the first page of the report but before the report header, you should design your report accordingly, that is, you should add the blank lines to the report header itself.

If you want the blank lines before the first detail line, you could do what JRB suggested, and add some blank records to the controlling cursor. Or, you could add the blank lines to the end of the report header, or to the end of the page header, using the Print When option to specify they should only be printed when the _pageno = 1.

If you want a blank page before the report (but I can't think why you should), just issue an EJECT before the REPORT FORM.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
You already have workable solutions from the previous posts.

Code:
x_LineFeed = ''
nEj=printers.invpre && (Inventory Pre-Printing ejection)
for x=0 to nEj step 1
Set device to printer
    * ?chr(13)
    x_LineFeed = x_LineFeed + chr(13)
endfor

REPORT FORM cGen+"orderticket.frx" NOCONSOLE noeject preview


Modify your Report and add this variable x_LineFeed where you want to print blank lines. Set the width of this such that it prints 1 char on 1 line. Test your report by adding any Printable character and then modify it with chr(13).
Set in 'General' tab 'Stretch with Overflow' *** very important *** else line feed will not work.

nasib
 
If SET device TO printer works, then EJECT would also work, it ejects a line, EJECT PAGE ejects a page. But I doubt this works in conjunction with FRX, as Mike says it prints whole pages, so it would then do a form feed anyway, before printing and your "manual" positioning may work but will be overridden.

Nasib Kalsi's idea is very good, this can be embedded in a FRX, you can inject both LOCAL and PRIVATE variables NOT defined as report variables and use them in expressions, the same way as cursor or table fields. And that opens all kind of possibilities. I don't think you need to narrow the field to print one char per line. Think of printing a multi line memo field, that will also print multi lines in a normal report field, even if it's not narrowed down. Printing a variable with CHR(13) will do the same.

That gives you several ideas to try out, now.

Bye, Olaf.
 
Hi Olaf:
I am sure chr(13) will do the trick but did not test it. So if chr(13) does not work, only then you require to set the printable length to 1 char in conjunction with 'Stretch with Overflow'. Other than this particular situation, I agree, char length could be any thing required by the report.

nasib
 
I could not imagine that 'set device to printer' is in the loop.

Code:
x_LineFeed = ''
nEj = printers.invpre && (Inventory Pre-Printing ejection)
for x = 0 to nEj step 1
    * Set device to printer
    * ? chr(13)
    x_LineFeed = x_LineFeed + chr(13)
endfor

REPORT FORM cGen+"orderticket.frx" NOCONSOLE noeject preview
 
I've been following this thread closely because report is ONE of my weak points.

I wonder rather having "Pre-Printing ejection", will it be OK to make use of the "Title Band" because it showed only once?
 
At this stage, it would be useful if Foxprox558 could come back and clarify what he is trying achieve (line feeds or page feed?), and also to let us know what he has tried so far, and what doesn't work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Lines are meaningless when dealing with proportional fonts. Fonts are sized in points, which is applied to the height of the font. The width is then changed to make the font look correct.

Craig Berntson
MCSD, Visual C# MVP,
 
Indeed that's a valid pint, Craig, but using a certain Font and Fontsize for the report control printing line feeds foxprox558 might get the positioning he wants.

@kamweng: As said twice already: Pre-Printing Eject won't matter before an FRX is printed, as in the normal case even with endless paper the printer driver will feed until the next paper start, when you start a new printjob, and an FRX always is it's own print job. Otherwise life would be hard in the normal case, wouldn't it?

If you SET DEVICE and do ??? or ?? you can't prepare a certain position, unless the printer driver used for the FRX is bad and not adjusting to a full page. Or you may have a receipt printer with no standard height pages but a cut off. That's normally not fedwith FRX reports, though.

Bye, Olaf.
 
Foxprox558,

You've had a lot of advice and help from several people over the last week. It would be really nice if you could come back and let us know if any of this was of any use to you - or, at least, to acknowledge the replies you received.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top