×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Printing Skips first page then prints a Blank page

Printing Skips first page then prints a Blank page

Printing Skips first page then prints a Blank page

(OP)
This code Right here always skips a First page the first page is BLANK then the correct Printing follows please help.
This is a Foxpro 9.0 code the code is for printing draft mode
ps. the printer is EPSON LQ-310 but I tried on other printer same result.

CODE --> 9.0

LOCAL mSpool
mSpool = GETPRINTER()
IF !EMPTY(mSpool)
	SET PRINTER TO NAME (mSpool)
	SET DEVICE TO PRINTER
	SET CONSOLE OFF 
	SET PRINTER ON 
&&	 SET PRINTER FONT "Courier New",4
*!*		SET PRINTER FONT "draft 12cpi"

*!*		LOCAL nHandle
*!*		nHandle = FOPEN("SAMPLE TEXT.TXT")
*!*		IF nHandle > 0
*!*			=FSEEK(nHandle,0,0)
*!*			DO WHILE !FEOF(nHandle)
*!*				@PROW()+1,0 say FGETS(nHandle)
*!*			ENDDO
*!*			=FCLOSE(nHandle)
*!*		ENDIF

	&&SET DEVICE TO SCREEN 
	&&SET PRINTER off 
	&&SET CONSOLE ON 
	&&SET PRINTER TO 
ENDIF


&&SET PRINTER ON 
&&SET PRINTER TO default

LOCAL lcHeading1,lcHeading2, lcHeading3, lcHeading4

	lcHeading1 = ALLTRIM(cHead)
	lcHeading2 = ALLTRIM(cSysName)
	lcHeading3 = 'Statement of Account'
	lcHeading4 = 'From : ' + MDY(Thisform.dtxtStartDate.value) + ' To ' + MDY(thisform.dtxtendDate.Value)
LOCAL headerswitch,lineperpage

headerswitch = 1
lineperpage  = 0






SELECT TEMPCUS
GO TOP 
SET ORDER TO TMP_CUSCD
DO WHILE !EOF() &&1
	
	***Header of Evry Page****
		lineperpage = 16 
		??? CHR(27)+CHR(33)+CHR(16) && reset to default font...
		??? CHR(27)+CHR(120)+CHR(0) && draft mode
		??? CHR(10)+CHR(27)+CHR(33)+CHR(17)
		??? CHR(27)+CHR(33)+CHR(04) && 12 cpi
		??? CHR(10) +PADR(lcHeading1,50," ")  && + SPACE(38) + 'Run Date: '+ DTOC(DATE())
		??? CHR(10) +PADR(lcHeading2,50," ") &&+ SPACE(38) + 'Run Time: '+ TIME()
		??? CHR(10) +PADR(lcHeading3,50," ")
		??? CHR(10) +PADR(lcHeading4,50," ")
		&&? CHR(27)+CHR(33)+CHR(04)
	**********************************************

		******Header Per Customer & Detailed Per Customer*****
		*****NOTE  Palehug ayaw helabte ang Spacing kay Maguba ag Report*******
		*****----Boy_Turko----------**********
				SELECT TEMP 
				SET ORDER TO TMP_CUSCD
				GO TOP 
				SEEK ALLTRIM(TEMPCUS.TMP_CUSCD)
				DO WHILE !EOF() &&2 
					
					IF ALLTRIM(TEMPCUS.TMP_CUSCD) = ALLTRIM(TEMP.TMP_CUSCD)
							IF headerswitch = 1 &&if1
								??? CHR(10)+ SPACE(100)+"Previous Balance " 
								??? CHR(10)+ SPACE(100) + TRANSFORM(temp->tmp_Pbal,'999,999,999.99')
								??? CHR(10)+ SPACE(100)+"OutStanding Balance " 
								??? CHR(10)+ SPACE(100) +	TRANSFORM(TEMP.TMP_sum,'999,999,999.99')
								??? CHR(10)+ 'Code      ' + PADR('   : '+ TEMP.TMP_CUSCD,50," ")
								??? CHR(10)+ 'Name      ' +PADR('   : '+ TEMP.TMP_CUSNM,50," ")
								??? CHR(10)+ 'Address   ' +PADR('   : '+ TEMP.TMP_ADDR1,50," ")
								??? CHR(10)+ 'Credit Limit ' +PADR('   : '+ TRANSFORM(TEMP.TMP_CR,'999,999,999.99'),50," ")
								??? CHR(10)+ 'Terms     ' +PADR('   : '+ TEMP->TMP_PAYTR,50," ")
								??? CHR(10)+REPLICATE('=',137) 
								??? CHR(10)+ 'Date         Doc No.       Type     SI/TDS Amount      Credit Adj      Debit Adj       Partial Payment    Balance    Floating    Age'				
								??? CHR(10)+REPLICATE('-',137)
								headerswitch = 0 
							ENDIF &&if1
							
						IF lineperpage 	> 60	
								lineperpage = 3
								EJECT 
								??? CHR(10)+ 'Date         Doc No.       Type     SI/TDS Amount      Credit Adj      Debit Adj       Partial Payment    Balance    Floating    Age'				
								??? CHR(10)+REPLICATE('-',137)
								??? CHR(10) + DTOC(TEMP.TMP_DATE) + SPACE(1) + PADL(ALLTRIM(TEMP.TMP_DOCNO),10,' ') + SPACE(4) + PADL(ALLTRIM(TEMP.TMP_TYPE),8,' ') + SPACE(4) + ;
								TRANSFORM(TEMP.tmp_dbqty,"999,999.99") + SPACE(7) + ;
								TRANSFORM(TEMP.tmp_ctqty,"999,999.99") + SPACE(4) +;
								TRANSFORM(TEMP.tmp_dtqty,"999,999.99") + SPACE(9) +;
								TRANSFORM(TEMP.tmp_crqty,"999,999.99") + SPACE(6) +;
								TRANSFORM(TEMP.tmp_bal,"999,999.99") + SPACE(1) +;
								TRANSFORM(TEMP.TMP_FLOAT,"999,999.99")  + SPACE(3) + IIF(!EMPTY(TEMP.TMP_AGE), ALLTRIM(STR(TEMP.TMP_AGE)) + ' Day(s) ', ' ')
								
						ELSE
							
								??? CHR(10) + DTOC(TEMP.TMP_DATE) + SPACE(1) + PADL(ALLTRIM(TEMP.TMP_DOCNO),10,' ') + SPACE(4) + PADL(ALLTRIM(TEMP.TMP_TYPE),8,' ') + SPACE(4) + ;
								TRANSFORM(TEMP.tmp_dbqty,"999,999.99") + SPACE(7) + ;
								TRANSFORM(TEMP.tmp_ctqty,"999,999.99") + SPACE(4) +;
								TRANSFORM(TEMP.tmp_dtqty,"999,999.99") + SPACE(9) +;
								TRANSFORM(TEMP.tmp_crqty,"999,999.99") + SPACE(6) +;
								TRANSFORM(TEMP.tmp_bal,"999,999.99") + SPACE(1) +;
								TRANSFORM(TEMP.TMP_FLOAT,"999,999.99")  + SPACE(3) + IIF(!EMPTY(TEMP.TMP_AGE), ALLTRIM(STR(TEMP.TMP_AGE)) + ' Day(s) ', ' ')
						ENDIF 
						lineperpage = lineperpage + 1
					ENDIF 		
					
					
					SELECT TEMP
					SKIP 
				ENDDO &&2
		*********************************************************
		********************************REPORT FOOTER**************************************
		IF  (lineperpage  + 22)  > 60
			EJECT 
			??? CHR(10)+REPLICATE('=',137) 
			??? CHR(10) + '1,000.00  x  ____________ = ____________  50.00  x  _____________ = _____________  |'
			??? CHR(10) + '  500.00  x  ____________ = ____________  20.00  x  _____________ = _____________  |'
			??? CHR(10) + '  200.00  x  ____________ = ____________  10.00  x  _____________ = _____________  |'
			??? CHR(10) + '  100.00  x  ____________ = ____________   5.00  x  _____________ = _____________  |'
			??? CHR(10) + '                                                                                   |'
			??? CHR(10) + 'Bills Amount           :  P _____________________________________________________  |'
			??? CHR(10) + 'DatedCheck Amount      :  P _____________________________________________________  |'
			??? CHR(10) + 'Coin Amount            :  P _____________________________________________________  |'
			??? CHR(10) + 'Total Amount           :  P _____________________________________________________  |'
			??? CHR(10) + 'PDC Received (Salesman)'
			??? CHR(10) + '------------------------------------------------------------------------------------'
			??? CHR(10) + '     Due Date             Bank Name          Check Number           Amount          '
			??? CHR(10) + '__________________   __________________   __________________   __________________   '
			??? CHR(10) + '__________________   __________________   __________________   __________________   '
			??? CHR(10) + '__________________   __________________   __________________   __________________   '
			??? CHR(10) + '__________________   __________________   __________________   __________________   '
			??? CHR(10) + '__________________   __________________   __________________   __________________   '
			??? CHR(10) + '------------------------------------------------------------------------------------'
			??? CHR(10) + '                                                 TOTAL >>>>>> ______________________'
			??? CHR(10)+REPLICATE('-',137)
			??? CHR(10) + 'Remarks : ' 
			??? CHR(10)
			??? CHR(10)
			??? CHR(10)
			??? CHR(10)
			??? CHR(10) + 'Prepared By: ' + ALLTRIM(_username)  + SPACE(25) + 'Noted By: ' + ALLTRIM(cNotedby) + SPACE(25) + 'Receive By:___________________'
			??? CHR(10)+REPLICATE('-',137)
		ELSE 
			??? CHR(10)+REPLICATE('=',137) 
			??? CHR(10) + '1,000.00  x  ____________ = ____________  50.00  x  _____________ = _____________  |'
			??? CHR(10) + '  500.00  x  ____________ = ____________  20.00  x  _____________ = _____________  |'
			??? CHR(10) + '  200.00  x  ____________ = ____________  10.00  x  _____________ = _____________  |'
			??? CHR(10) + '  100.00  x  ____________ = ____________   5.00  x  _____________ = _____________  |'
			??? CHR(10) + '                                                                                   |'
			??? CHR(10) + 'Bills Amount           :  P _____________________________________________________  |'
			??? CHR(10) + 'DatedCheck Amount      :  P _____________________________________________________  |'
			??? CHR(10) + 'Coin Amount            :  P _____________________________________________________  |'
			??? CHR(10) + 'Total Amount           :  P _____________________________________________________  |'
			??? CHR(10) + 'PDC Received (Salesman)'
			??? CHR(10) + '------------------------------------------------------------------------------------'
			??? CHR(10) + '     Due Date             Bank Name          Check Number           Amount          '
			??? CHR(10) + '__________________   __________________   __________________   __________________   '
			??? CHR(10) + '__________________   __________________   __________________   __________________   '
			??? CHR(10) + '__________________   __________________   __________________   __________________   '
			??? CHR(10) + '__________________   __________________   __________________   __________________   '
			??? CHR(10) + '__________________   __________________   __________________   __________________   '
			??? CHR(10) + '------------------------------------------------------------------------------------'
			??? CHR(10) + '                                                 TOTAL >>>>>> ______________________'
			??? CHR(10)+REPLICATE('-',137)
			??? CHR(10) + 'Remarks : ' 
			??? CHR(10)
			??? CHR(10)
			??? CHR(10)
			??? CHR(10)
			??? CHR(10) + 'Prepared By: ' + ALLTRIM(_username)  + SPACE(25) + 'Noted By: ' + ALLTRIM(cNotedby) + SPACE(25) + 'Receive By:___________________'
			??? CHR(10)+REPLICATE('-',137)
		ENDIF 	
	
		********************************END FOOTER******************************************

		&&SET PRINTER TO 
		headerswitch = 1
		SELECT TEMPCUS
		SKIP 		
		EJECT 
ENDDO &&1
	&&SET DEVICE TO SCREEN 
	&&SET PRINTER off 
	&&SET CONSOLE ON 
	SELECT TEMP
	SET ORDER TO TMP_CUSCD
	SET PRINTER TO NAME (mSpool)
	&&SET PRINTER TO 






RE: Printing Skips first page then prints a Blank page

I don't know, I never print in draft mode. Of course, there is the Generic Text printer for that, you might consider changing to use that printer and configure it to use the EPSON for output.

I can only make the guess since you never SET PRINTER OFF after your EJECT you keep open a single print job and then you may just see the EJECT at the end of previous printing become effective when you start printing the next report.

So I'd first change to finish the print mode after your final EJECT, so it becomes forced to be executed and not just queued in the print job all this code causes. Then, if that still doesn't work, go for using the Generic Text printer.

Besides your wide code lines cause this thread to appear wider than HD screen size, please consider editing your post and replace the longest code lines with ... we don't need to see every ??? command to get a hint on your problem. Ideally try to come up with a very short example, perhaps even just printing a single line of content will also reproduce the problem, makes it far easier to glance over your code.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Printing Skips first page then prints a Blank page

Some dot-matrix printers have a setting that tells it to do a page throw at the start of the print job. This was sometimes needed to ensure that the paper was correctly aligned.

I don't know if that applied to the LQ310. You should check the printer's manuals. It might be specified by a hardware switch (a dip switch) or alternatively by an escape sequence.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Printing Skips first page then prints a Blank page

(OP)
Mr. Olaf. thank you for the reply im sorry for the long code
for the EJECT as you can see it is inside a loop so that I can EJECT paper every other document is there more efficient way to do here? if put SET PRINTER OFF after the EJECT INSIDE on a loop is that be ok?



Mr. Mike thankyou for your reply
I don't think so its on the printer
the problem cause by this code

CODE -->

??? CHR(27)+CHR(33)+CHR(16) && reset to default font...
		??? CHR(27)+CHR(120)+CHR(0) && draft mode
		??? CHR(10)+CHR(27)+CHR(33)+CHR(17)
		??? CHR(27)+CHR(33)+CHR(04) && 12 cpi
		??? CHR(10) +PADR(lcHeading1,50," ")  && + SPACE(38) + 'Run Date: '+ DTOC(DATE())
		??? CHR(10) +PADR(lcHeading2,50," ") &&+ SPACE(38) + 'Run Time: '+ TIME()
		??? CHR(10) +PADR(lcHeading3,50," ")
		??? CHR(10) +PADR(lcHeading4,50," ")
		&&? CHR(27)+CHR(33)+CHR(04) 


this allows the printing to draft mode and set its font
if this is remove the printing is smooth but the fonts and the speed are horrible.
is CHR(27) may cause all of this?
is there any way I can print on visual foxpro on a very fast rate on other way any suggestion or idea
Thank You.

RE: Printing Skips first page then prints a Blank page

Quote (elbuff)

if put SET PRINTER OFF after the EJECT INSIDE on a loop is that be ok?
Not inside a loop, i didn't get this, also because of the length of the loop body, but yes, I see the ENDDO ending the WHILE loop.

I guess the last eject is the one that'll be executed with the next printing, as you don't finalize your print job, really.
After the loop you have many things commented, why? I guess that code should be uncommented and mended like this:

CODE

SET PRINTER TO 
SET PRINTER OFF
SET DEVICE TO SCREEN 
SET CONSOLE ON
SELECT TEMP
SET ORDER TO TMP_CUSCD 

Quote (elbuff)

is CHR(27) may cause all of this?
That indicates to me you inherited the code and don't know in detail what it's doing. CHR(27) is turning ASCII Code number 27 for ESC into the ASCII character (CHR=character) for the output of it.
And printer like your assumingly old EPSON but almost any older printer have a command set triggered by ESC. So no, that doesn't mean CHR(27) is the culprit. In itself it tells the printer, "a command follows", and the next few CHR() are the commands with parameters. The comments tell what commands are sent, and DRAFT mode is faster but less exact printing, in todays printers typically still very readable. That's the main speed up on top of a simpler font. Remove these lines and you print slower, and I asloe don't guess you solve the EJECT problem. Unless the only undocumented ESC sequence in your code, ??? CHR(10)+CHR(27)+CHR(33)+CHR(17) contains an ESC sequence of a command for eject, but then you'd have empty pages inbetween every printed page. From the line below it looks like a CPI change, too. Maybe just to make one line higher.

No, your problems are ejects when starting to print, aren't they? That has nothing to do with the draft mode or font, ejects are caused by the EJECT command and then perhaps as Mike says by a default of the printer to start each print job with an EJECT, especially if endless paper is used this way a printer normally positions onto the next perforation and page start. But that has absolutely nothing to do with any of the ESC sequences, if their comments are pointing out correctly what they do, there is nothing related to ejecting paper, is there?

Let me finish with a simple question: As each loop iteration ends with an EJECT, does printing overall end with an EJECT or do you need a manual eject at the end before pulling out the paper? If that's the case you have your indication the last EJECT still hangs there and wasn't output by the printer, it's still in printer queue memory. SET PRINTER OFF should cause that final EJECT then and then you'd have no first eject with the next print job you start.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close