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!

setting printer from program 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am moving my program code from an old version (2.0 I guess)
to vfp 6. I am not familiar with OOPS and still using old foxbase
logic and commands. I have to print several reports on different
paper size and orientation. For use with one machine I can create
serveral printers (each with different setting but the same driver)
but if I want to use the application over a network, I just can't
create sets of printers (for some shared printers on the network)
for every machine. There should be a way of passing settings to the
printers just as you did with the "printer setting dialog" but from
within the program code. Can someone please kindly tell me how to
do so. Many thanks
 
Since the actual orientation, tray, etc. are stored in the report file itself, you have to either create multiple reports for each printer or remove the data in those fields and define different printers.
To select a different printer programmatically, use the statement:

SET PRINTER TO "\\machine_name\printer_name"
like "\\FS1_DATA\HP LaserJet II"

or for NT
SET PRINTER TO NAME "\\machine_name\printer_name"

Note that when you specify a printer, the name is case-sensitive.

To get rid of the data in the report file which is saved each time you save the report, USE the report file (?.FRX),
BROWSE it, and remove everything in the Expr, Tag and Tag2 fields.

Dave S.
 
Thanks Dave, but no. I am not using "report from " and all that stuff.
I just use
set device to printer
@ x, y say ........
this kind of primitive method.
Your suggestion seem to say that I have to do something interactive, and
after I have print but what I am trying to achieve is setting the printer
before the printing and without users intervention.

But thanks anyway for the help, it gives me some insight for somewhere
else.
 
Softlab,

There is certainly a way of passing formatting codes to printers, and it is through the "ESCAPE CODES" (old fashion but possible). The problem is this codes differs from one printer technology to another and you need to know where you are printing (so it may require user intervention).

The escape codes are usually descripted in the printer manual.

Anyway, I suggest you to be brave and dare getting into the report builder world! It's a one-way walk! :)

(Let us know if this helped)

David.
 
David,

tks for response, but I think you are on the wrong track. The method you are
suggesting works in DOS, (infact that is what exactly what I do when my
application is in DOS mode) but now I am talking in window mode and I don't
think the printers care about the 'ESC codes' you send to them.

 
They will care about the printer codes as long as you aren't going through a Window's printer driver that ingores or strips them out. Try set the printer to one that uses the "Generic / Text Only" printer driver.

Rick
 
This will work for what you want to do.

SET CONSOLE OFF
SET PRINTER TO "\\machine_name\printer_name"

such as "\\FS1_DATA\HP LaserJet II"

or for NT
SET PRINTER TO NAME "\\machine_name\printer_name"

then,
SET DEVICE TO PRINTER
SET PRINTER ON

@ 1, 1 SAY whatever
@ 2, 1 SAY whatever
.
.
.

or,

?whatever
?whatever
.
.
.
SET PRINTER OFF
SET PRINTER TO
SET CONSOLE ON
SET DEVICE TO SCREEN

Dave S.
 
Thanks Dave,

That is exactly the kind of program code I have, but what about
setting the page width, page length, orientation, color (mono or
color) all that stuff. Can you elaborate further.

Thanks in advance

 
For that you will need to use the printer escape codes.
There are a couple threads related to this:

thread182-49491
thread182-109272

Dave S.
 
Dave S,
Thanks for the technique-
I am trying to get FP 2.0 application writing to DOS printer to work under VFP7. I am using rawprintvcx.zip
to print with the print control characters by capturing the print image to a .txt file and then printing the text file via rawprint. This requires SET DEVICE To filename. The problem I ran into was that some programs, during the report set device back and forth to screen. SET DEVICE TO filename does not support ADDITIVE as does SET PRINTER. Also, the programs use both ?, ?? along with @ line,loc Say.

I used your above example of SET PRINTER but used
SET PRINTER TO FILE filename ADDITIVE. This worked GREAT.

I ran the following code 3 times-
the lines were appended to the end of the existing file
including the page eject.

THANKS!
HerbG

...
SET PRINTER TO c:\temp\file1.txt addi
SET DEVICE TO print
SET PRINTER on
@ 1,1 say 'line 1 with @'
@ 2,1 say 'line 2 with @'
@ 1,1 say 'line 1 with @ again'
? 'line with ?'
?? 'line with ??'
@ 1,1 say 'line 1 with @'
@ 2,1 say 'line 2 with @'
@ 1,1 say 'line 1 with @ again'
? 'line with ?'
?? 'line with ??'
SET PRINTER off
SET PRINTER to
SET DEVICE TO screen
....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top