|
| |
Knowledgebase
>>ITEM: N01020
>>DATE: March 26, 1998
>>TYPE: Information
>>TITLE: Cannot print to desired network printer in FPW, VFP
>>PRODUCT(S):
NetLib 2.5x for FPW
>>PLATFORM(S):
Windows for Workgroups 3.1x
Windows 95
Windows NT
>>SUMMARY:
Print output always goes to default Windows printer, regardless of
SET PRINTER TO, N_CAPSET (N_T_CAPSET, N_D_CAPSET) and N_REDIRECT settings.
>>MORE INFORMATION:
There are two components to Windows printing:
 | The printer driver: which is based on the hardware type of the physical printer (e.g., HP LaserJet 4PS,
Lexmark Optra E+,...)
 | The printer destination: which determines the
physical location of the printer. Some possible printer destinations include:
 | A Local port, such as LPT1, COM2, etc.
 | A "redirected" local port, such as LPT1=\\Isis\Optra.
 | A remote share, such as "\\Isis\Optra". This will print directly to the remote share, completely bypassing either a local port or a redirected local port. This capability did not exist in Windows 3.1 or DOS.
| | |
| |
Under FPW or VFP, regardless of the settings of SET PRINTER,
SET DEVICE, etc., your output will *always* go to the default Windows
printer. If your default Windows printer is a local port
(e.g., LPT1) or a redirected local port (e.g.,
LPT1=\\Isis\Optra), then using N_CAPSET or N_REDIRECT to capture
the output of the printer port will work. However, if your
default Windows printer goes to a remote share (e.g.,
\\Isis\Optra), Windows completely bypasses any LPT port, so there
is nothing to "capture".
>>RESOLUTION/FIX:
There are two basic ways to address the problem. Which you
choose depends largely on these factors:
- The number of different print destinations. Do you have 3 printers or 300
printers?
- The number of different models of printers. Are all the printers either
HP LaserJet 4 PS or Lexmark Optra
E+, or are there dozens of different kinds?.
- How often you move around printers. Once the new Lexmark 5700 is attached to
\\Isis\Lex5700, will it stay there, or could it possibly be
\\Osiris\Lex5700 tomorrow?
***Option 1
This is most suitable if you have a small number of known
printers that your output will go to.
- Using the Windows Control Panel, add a printer for each of the
output destinations. This may include your local
printer (which is probably the default Windows printer) and shared network printers. Under "Print to" or "Print to the following port" specify the share name of the
network printer (e.g., \\Isis\Optra). Give each printer a name
that will be readily intelligible,
e.g., "Optra E On Isis", "HP5 On Isis", "HP5 On Osiris".
NOTE: In many instances, this printer setup step has been
done previously.
-
Use the function SETDEFAULT (found in WINPRN) to set the default Windows printer, so that it will direct the output to the appropriate location.
You will also find GETDEFAULT (which gets the current default Windows
printer) and LISTPRINT (which lists the Windows printers) in WINPRN.
For example:
* get current default Windows printer
cDefaultPrn = GETDEFAULT()
* set new default
=SETDEFAULT("Optra E On Isis")
* print report
* print output always goes to default Windows printer
REPORT FORM test TO PRINT
* restore original default Windows printer
=SETDEFAULT(cDefaultPrn)
***Option 2
This is a more flexible option It is suitable when you have many printers, or an undetermined number.
-
Using the Control Panel, add a printer for each of the
different *types* of printers (*not* for
each print destination.) If there were 20 HP5
printers on 20 different machines, you would only add a single HP5
printer. Under "Print to" or "Print to the following port"
specify a local port LPT1, LPT2, etc. Give the printer a name
that will be readily intelligible,
e.g., "Optra E On LPT1", "HP5 On LPT2".
- Inside your program, use SETDEFAULT (found in WINPRN) to select the appropriate default Windows printer (and thus
the printer driver). Then use N_MAPDRIVE or N_REDIRECT to
redirect the local device.
For example:
* get current default Windows printer
cDefaultPrn = GETDEFAULT()
* set new default
=SETDEFAULT("HP5 On LPT1")
* cancel existing LPT1 redirection
=N_REDIRECT("LPT1","")
* Set new redirection
=N_REDIRECT("LPT1","\\Isis\HP5",3)
* print report
* print output always goes to default Windows printer
REPORT FORM test TO PRINT
* cancel redirection
=N_REDIRECT("LPT1","")
* restore original default Windows printer
=SETDEFAULT(cDefaultPrn)
***Option 3
In many instances, you will probably have a combination of
Options 1 and 2. For example, you may have several fixed
destinations (Option 1) for your standard Windows programs, such
as word processing, spread sheets, web browser, etc.; as well as
several variable destinations (Option 2) for use by your program.
>>EXAMPLE(S):
See WINPRN for additional examples.
>>SEE ALSO:
N01021,N01022
>>COPYRIGHT 1998 Communication Horizons
All rights reserved worldwide.
No distribution without specific consent of publisher.
Knowledgebase
Top Home
| | |
|