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

[SET PRINTER TO] CR/LF as last char instead of FormFeed

Status
Not open for further replies.

DirkVFP

Programmer
Aug 25, 2005
57
0
0
NL
Hello,

At the moment I'm printing labels with an Intermec PD4 printer
in this way:

Code:
SET PRINTER TO NAME "intermec"
SET PRINTER ON 
SET CONSOLE OFF

? "N"
? "B20,35,0,E30,3,2,150,B,"+CHR(34)+ALLTRIM(list.barcode)+CHR(34)
? "A395,63,0,5,2,2,N,"+CHR(34)+ALLTRIM(list.code)+CHR(34)
? "LO20,230,750,2"
? "A20,260,0,4,1,2,N,"+CHR(34)+ALLTRIM(list.name)+CHR(34)
? "A20,327,0,4,1,2,N,"+CHR(34)+ALLTRIM(list.address)+CHR(34)
? "A20,394,0,4,1,2,N,"+CHR(34)+ALLTRIM(list.postal_code)+CHR(34)
? "A20,461,0,4,1,2,N,"+CHR(34)+ALLTRIM(list.city)+CHR(34)
? "P1"
?

SET PRINTER OFF
SET PRINTER TO 
SET CONSOLE ON

But when I use the printer in dump mode, I see that the last character to be sent to the printer is a formfeed (ascii 12) character! It however should be a carriage return/line feed, which the printer ESim langauge needs so it knows the command line ends and it can start printing the label.

Hard coding an extra line with
Code:
? chr(13)+chr(10)
does not help me.

Any ideas?

Thanks,
Dirk
 

Dirk,

This is exactly what I would expect. The SET PRINTER TO will issue the formfeed. The solution is to keep the print job open until you have finished printing the last label, and then do the SET PRINTER OFF / SET PRINTER TO.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Dirk,

This is exactly what I would expect. The SET PRINTER TO will issue the formfeed. The solution is to keep the print job open until you have finished printing the last label, and then do the SET PRINTER OFF / SET PRINTER TO.

Mike

Mike,

I assume you mean with 'keeping the printjob open' as not calling SET PRINTER TO? If that's the case I cannot use your solution. These labels are most of the time printed once per piece. So after each label I need to call SET PRINTER TO so it should start printing the label. But alas, SET PRINTER TO puts a formfeed on the end of it all, while my printer is waiting for a crlf as a last character.
 
Hi Dirk,

Check the system variable _PADVANCE. If you set it to LINEFEEDS and use _PLENGTH you may be closer to what you need.

Regards,

Mike
 
Mike,

What would be the best way to incorporate your tip into my previously shown code? I tried this:
Code:
_PADVANCE = "LINEFEEDS"
_PLENGTH = 10
ON PAGE AT LINE 10 EJECT PAGE 

SET PRINTER TO NAME "intermec"
SET PRINTER ON && Enable output to the printer
SET CONSOLE OFF

? "N"
? "B20,35,0,E30,3,2,150,B,"+CHR(34)+ALLTRIM(debiteur.scan)+CHR(34)
? "A395,63,0,5,2,2,N,"+CHR(34)+ALLTRIM(debiteur.zoekc)+CHR(34)
? "LO20,230,750,2"
? "A20,260,0,4,1,2,N,"+CHR(34)+ALLTRIM(debiteur.naam)+CHR(34)
? "A20,327,0,4,1,2,N,"+CHR(34)+ALLTRIM(debiteur.adres)+CHR(34)
? "A20,394,0,4,1,2,N,"+CHR(34)+ALLTRIM(debiteur.postc)+CHR(34)
? "A20,461,0,4,1,2,N,"+CHR(34)+ALLTRIM(debiteur.plaats)+CHR(34)
? "P1"
?

SET PRINTER OFF
SET PRINTER TO 
SET CONSOLE ON

But this didn't help at all. Could you please give me some hints here? The VFP7 help does not provide a good example. It lacks more info in this subject. Looking up _PLENGTH gives me:
Code:
Included for backward compatibility. Use the Report Designer instead.

;-)
 
Hi Dirk,

My understanding of _PADVANCE and _PLENGTH is that when _PADVANCE="LINEFEEDS" and an EJECT is issued linefeeds are sent to the printer until _PLENGTH is reached.

You probaly need to SET PRINTER TO NAME "intermec" prior to setting _LINEFEEDS.

The other possibility is to create a string that will do the complete print job and bypass the driver with ???.

Example:
Code:
SET PRINTER TO NAME GETPRINTER()
_PADVANCE = "LINEFEEDS"
_PLENGTH = 15
LFCR = CHR(13) + CHR(10)
myString = ""
FOR NUM = 1 TO 10
	myString = myString + "This is line " + ALLTRIM(STR(NUM)) + LFCR
NEXT NUM
??? myString
EJECT
SET PRINTER TO

Regards,

Mike
 
Hi Dirk,

Playing around on my handy-dandy Okidata ML 320, I found that when I issued the EJECT, _PLENGTH number of LFCR's went to the printer.

Interesting.

Regards,

Mike
 
Hi Dirk,

Playing around on my handy-dandy Okidata ML 320, I found that when I issued the EJECT, _PLENGTH number of LFCR's went to the printer.

Interesting.

Regards,

Mike

Thanks for your example Mike, now I got something to work with. I'll check on my printer what behaviour it shows with you example.
 
Mike,

With the help of your example I got things working as intended!
Code:
*** SET PRINTER ON/OFF are disabled
*** They only seem to slow down the printing process
*** This example prints one label is it should: right away.
*** SET PRINTER TO also send a CRLF 

SET PRINTER TO NAME "intermec"

_PADVANCE = "LINEFEEDS"
_PLENGTH = 1 

&&SET PRINTER ON
SET CONSOLE OFF

CRLF = CHR(13) + CHR(10)

myString = "N" + CRLF
myString = myString + "B20,35,0,E30,3,2,150,B,"+CHR(34)+ALLTRIM(debiteur.scan)+CHR(34) + CRLF
myString = myString + "A395,63,0,5,2,2,N,"+CHR(34)+ALLTRIM(debiteur.zoekc)+CHR(34) + CRLF
myString = myString + "LO20,230,750,2" + CRLF
myString = myString + "A20,260,0,4,1,2,N,"+CHR(34)+ALLTRIM(debiteur.naam)+CHR(34) + CRLF
myString = myString + "A20,327,0,4,1,2,N,"+CHR(34)+ALLTRIM(debiteur.adres)+CHR(34) + CRLF
myString = myString + "A20,394,0,4,1,2,N,"+CHR(34)+ALLTRIM(debiteur.postc)+CHR(34) + CRLF
myString = myString + "A20,461,0,4,1,2,N,"+CHR(34)+ALLTRIM(debiteur.plaats)+CHR(34) + CRLF
myString = myString + "P1" + CRLF

??? myString
EJECT 

&&SET PRINTER OFF
SET PRINTER TO 
SET CONSOLE ON

I find it strange however that in previous try outs (with _PADVANCE set to "LINEFEEDS") the SET PRINTER TO commands sent a Formfeed, but now it sends a CRLF. I don't know the mechanics under the hood but it seems _PADVANCE and EJECT affect SET PRINTER TO.

What the difference between the ? and ??? commands is, isn't clear to me yet. My FoxPro hackers guide doesn't help me much there either:
???
This operator sends its operands directly to the printer ... sort of.

Usage ??? cCodes

In FoxPro/DOS, this was an incredibly useful operator. In simple cases, we used it to send printer control codes so we didn't have to mess with FoxPro's complex printer driver system. Unlike characters sent with other commands, these don't change FoxPro's tracking of the position of the print head in PCOL().

In Visual FoxPro, however, ??? is useless. In order to actually send the characters, you have to issue SET PRINT TO (which terminates the print job and gets Print Manager to actually send something through). We don't think our users want us to waste a sheet of paper every time we want to send control codes. Even if you can get the characters through to the printer, the next thing you send (like a report) reinitializes the printer and your settings are lost. Forget it—just don't bother.

Besides, it's not the Windows way. Printer drivers are our friends (at least most of the time).

Anyways, thanks so far for your help, it works as it should :)

Kind regards,
Dirk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top