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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Foxpro print command issues

Status
Not open for further replies.

Alexengland1

IS-IT--Management
Mar 18, 2004
88
US
This happens on every printer we have in the building. Any program you print from that accesses the printer settings program, spits out a blank page first, then the document. I am kind of an amature programmer and I'm at a loss to what might be causing the problem. Even just the following If/endif statement will cause the extra page.

if upper(orient) = "P"
??? chr(27)+"&l0O"
else
??? chr(27)+"&l1O"
endif

Any help would be greatly appreciated.
 
Alexengland1,

Are you sure that any print command will cause this to happen, or is just when you send an escape sequence?

If the latter, it could be a side-effect of the particular escape sequence you are sending.

What happens when you print a VFP report to the printer? If you could try that and report back, it would help narrow down the possibilities.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Reports print fine, everything else prints fine. Its only when the program containing the above mentioned statement is access that the blank page is spit out. This was originally in Foxpro 2.5 and we had the problem then too. It has since been converted to VFP 8.0 and I have been given the task to find out how to stop this problem.

Is there any variation on the stament above that my put an end to this problem? Thanks
 
Are you printing through the Windows printer drivers? (What are the spooler settings?) Are you using the Generic / Text Only driver? What OS(s) are you running under?

Rick
 
The machines in the office are all running Windows XP. The printer drivers are all PCL6 drivers, which are running off of our Windows 2000 print server. The ques settings are set to spool the document and start printing immediately. I'm assuming that was what you were looking for.

We just recently switched the print ques over from our Novell server, because we are in the process of phasing out Novell. So, this issue existed under Novell and now our Windows print ques.
 
Alexengland1

only when the program containing the above mentioned statement is access that the blank page is spit out.

In that case, it is almost certainly that particular escape sequence that is causing the problem. Why not simply omit those lines of code?

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Let me clarify. The program in question, is a basic program to set font type & page orientation on the printer. I did not write the program, but I spent some time messing with it and afer doing some checking, it appears that any line that starts with "??? chr(27)+...." causes the extra page. I have gone thru the whole program and REMed out each line one by one to find out what was causing the problem and thats the conclusion I came to. Here is the whole program, its fairly small. Please take a look at it and let me know if there is a different way to set these parameters. Thanks.

*************************** HPS CODE *****************************
* UDF hps, HP laserjet setup
* Based on HPFCHAR2.PRG by Menachem Bazian in foxtalk 8/90
*
function hps
parameters orient,pitch,lpi

IF SYS(101) = "SCREEN"
SET DEVICE TO print
ENDIF
SET PRINTER on
if upper(orient) = "P"
??? chr(27)+"&l0O"
else
??? chr(27)+"&l1O"
endif
xpitch=pitch
if xpitch = 16
xpitch = 17
endif
if pitch = 0
??? chr(27)+"(s1P"
else
??? chr(27)+"(s0p"
??? chr(27)+"(s"+alltrim(str(xpitch))+"H"
endif

point size
strpoint = alltrim(str(72 / lpi))
mstr=chr(27)+"(s"+strpoint+"V"
??? mstr

force upright style
??? chr(27)+"(s0S" && upright style
??? chr(27)+"(s0B"

symbol set
?? chr(27)+"("+"R8"

type face
do case
case pitch = 10
??? chr(27)+"(s"+"0034"+"T"
case pitch = 12
??? chr(27)+"(s"+"0035T"
case pitch = 16
??? chr(27)+"(s0036T"
endcase
vmi
??? chr(27)+"&l"+alltrim(str((48 / lpi ),8,4))+"C"

Suppress skip @ eop
??? chr(27)+"&l0L"
set print &old_prt_st
return (0)
 
Alex,
While you want a PCL printer, you need to "front" it with the Generic / Text Only Printer Driver. This old "DOS" code was never meant to go through a Windows printer driver - even the PCL6 drivers.

Note: If the Printer isn't PCL exclusive, you may need to add some additional code to switch/make sure it's in that mode.

Rick
 
Alexengland1,

But you don't have to send the escape sequences directly to the printer in order to set the fonts, etc. In VFP, ? and @/Say take optional font and style clauses that do that job.

Your strategy should be to get rid of all the code that involves sending CHR(27) + <something>, and to use the actual printer driver (not generic/text only), with the appropriate clauses.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
rgbean,
I tried that and it didn't seem to make any difference. However I did not check to see if the printer was PCL exclusive so I will have to double check that one.

Mike,
That was my first suggestion to our programmer here, but here is the issues. We just converted from Foxpro 2.5 to VFP 8 about 6 months ago, and almost all of the 300+ programs are still DOS based coding. Half of those programs rely on this print program for font & page layout. Its going to take a while for us to convert them all. So what I'm looking for is a temporary fix until we are able to get to that point and get rid of this program all together. Sorry guess I should have clarified that in the beginning. Any other thoughts?

 
Alex,

Is the code sample above the actual code? It restores the old printer without saving it in the first place and there are several lines that should generate errors.

The ??? bypases the printer drivers and goes straight out the port. If even a single character was received by the printer as a non control character (random space perhaps) it would be in the buffer and would cause a end of job print page when the actual job starts. It would look a lot like an eject......does anything at all print on the ejected page?

Regards,

Mike
 
I concur with Mike:
If even a single character was received by the printer...

If you send a single character to the printer whether it be from ???, ??, @...SAY or whatever, even to tell it to change a font, it may not print but it is a portion of a print job. So the next time you send a print job to the printer to have it start printing on row 1, it is going to advance to the next row 1, which will be a new page.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
It appears that the problem code is changing the orientation. If there is even a single character in the print job, changing orientation will cause a page eject. Laser printers cannot do portrait and landsacape printing on the same page. There is a font rotation command to accomplish this.
 
Alexengland1,
... We just converted from Foxpro 2.5 to VFP 8 about 6 months ago...
Rick is right about the Generic / Text Only Printer Driver. I use to make VFP programs to print in text mode (not graphics as in FRX reports) and at the same time, control the character pitch (normal or condensed), page orientation, lines per inch, etc. If you send values between CHR(0) to CHR(31), you may need to re-assign control-character-sequence codes (or whatever you may call it) under the printer driver's character set properties (I forgot the actual description). For example, the default character value for CHR(1) should be replaced with ^A (CTRL-A). I was successful in doing this under Windows 3.x/95/98 but wasn't able to try it out in Win XP (I could not find the properties to re-assign character codes).
And one important thing is to avoid the use of @...SAY when doing this in VFP. It could cause the page to advance and may neutralize the CHR codes initally passed by the program. Just use the ?/?? commands.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top