Special File Handling
*WINPRT* Windows Printing
   
Formats 1. Open Device File: OPEN (chan[,fileopt])"*WINPRT*[;Q_name[Q_options]"
2. Open for Read-Only: OPEN INPUT (chan[,fileopt])"*WINPRT*[;Q_name[Q_options]"
3. Open for [WDX]: OPEN [INPUT] (chan[,fileopt])"[WDX]*WINPRT*[;Q_name[Q_options]"
 
Where:
chan Channel or logical file number; e.g., OPEN (1)"*winprt*"
fileopt File options. Supported options for opening *WINPRT* include:
  ERR=stmtref Error transfer.
OPT=char$ File open options. See About File OPEN Options. To obtain the current OPT= value, use the OPT( ) Function.
Q_name Print queue to open. (If you omit the queue name, a printer selection dialogue appears at run time to let the user select the printer and its properties.) Valid Q_name options include:
  • OS name of an existing physical print queue on the local Windows machine;

OPEN(14)"*WINPRT*;HP LaserJet".

  • OS name of print queue ON resource
    (UNC, format: ON \\machine\resource for any shared resource or ON LPT# for direct local access to a port):

OPEN(14)"*WINPRT*;HPLaserJet ON \\Main_Server\P Laser"
OPEN(14)"*WINPRT*;LP ON LPT1"

  • One of the following queue selection keywords:
    ASIS Most recently selected printer and properties.
    DEFAULT Printer currently "Set As Default" in the system; e.g.,
    OPEN (30,ERR=9900)"*WINPRT*;DEFAULT".
    NORMAL Normal dialogue with page range (no paper size, source tray).
    SETUP Setup dialogue with paper size, source tray (no page range). While the Q_name is optional, it is mandatory in directives if you want to assign or override queue properties (Q_options, below). See also *WINPRT* / *WINDEV* Queues.
Q_options Override printer properties. String expressions. You can override printer- and driver-specific values by assigning a new value to the queue (e.g., copies=2 instead of copies=1). Use semicolons to separate items if you have a list.
Q_options
must be preceded by a Q_name; i.e., HP LaserJet in the example below, or a queue keyword like DEFAULT).
Specific properties are listed under WINPRT_SETUP Properties. See also *WINPRT* and *WINDEV* Queue Properties.

Example: OPEN(30)"*WINPRT*;HP LaserJet;orientation=landscape;copies=3"

[WDX] *WINPRT* is specific to Windows operating systems. Under UNIX, ProvideX automatically directs *WINPRT* access to the WindX client; e.g., OPEN (14)"*winprt*" !For the PC client from UNIX host. In a Windows NT environment, you are opening the *WINPRT* printer relative to the host unless you prefix the printer name with the [WDX] tag; e.g.,

OPEN (14)"*winprt*" !For the NT host
OPEN (14)"[WDX]*winprt*" !For the NT PC client

  The *WINPRT* Keyword is not case-sensitive. Special device filename, enclosed in quotation marks within OPEN directive. (Include asterisks in syntax.)
   
Description Use *WINPRT* with your OPEN and/or OPEN INPUT directives to gain standard API access to the Windows print subsystem. For raw or pass-through mode, use *WINDEV* Raw Print Mode.


*Note* For use in WindX or Windows only.


  The device driver for your given printer interprets the data you send to the *WINPRT* channel, then sends the output to the Windows spooling subsystem for transmission to its destination. You can identify the LPT for direct local access to the port or use UNCs (Universal Naming Conventions) for transmissions to a shared resource. LPT identification is not recommended under Windows NT.

ProvideX recognizes *WINPRT* as a special device file in your OPEN [INPUT] directive and deals with it internally in the language at run time. ProvideX returns an Error #12: File does not exist (or already exists) on the OPEN if no printers are installed or if the user presses the Cancel button in a printer selection dialogue. (This error can also occur if no printer is "Set As Default".)

Some printer device drivers are unable to handle invalid Q_options; i.e., unknown property assignments and/or syntax errors (like range=1,5instead of the correct range=1:5). The result can be unpredictable. The driver can even cause your ProvideX session to hang during the open. If you encounter unexpected problems, invalid Q_options for the given driver are the likely cause.



*Note* Escape sequences are not allowed with *WINPRT* and may have an unpredictable effect on the device and/or printer driver. If you need access to the print subsystem to send PCL, escape sequences, etc., use *WINDEV* Raw Print Mode.


   
Format 1 Open Device File

OPEN (chan[,fileopt])"*WINPRT*[;Q_name[Q_options]"

Use this format to open the *WINPRT* device file. ProvideX will recognize and deal with this special device file at run time to give you access to the Windows print subsystem. Then you can send print jobs to the given queue on your open channel. See *WINPRT* / *WINDEV* Printing Examples.



*Note* Some device drivers issue an extra blank page (some even hang) if an open channel is closed too quickly or if nothing is printed to the channel before it's closed. Use the OPEN INPUT directive (described next) to bypass problems of this nature.


   
Format 2 Open for Read-Only Mode

OPEN INPUT (chan[,fileopt])"*WINPRT*[;Q_name[Q_options]"

Use the OPEN INPUT directive to open *WINPRT* in read-only mode when you only want to determine the properties (Q_options) of a printer without sending a physical job. With an OPEN INPUT directive, you can open the printer, process your queries, and close the channel without starting a physical job.

Example:

Use the WINPRT_SETUP READ PROPERTIES directive, a 'FONT'(LIST) graphics mnemonic or the MXC( ) and MXL( ) functions without generating a FormFeed:

IF WDX%<>$00$ THEN OPEN INPUT (30)"*WINPRT*;ASIS"
X$='FONT'(LIST*,30) ! Get font list
-:?X$
System,Fixedsys,Terminal,MS Serif,MS Sans Serif,Courier,Symbol,Small Fonts, Modern,
FrameMakerSmallFont,Marlett,Arial,Courier New,Times New Roman, ... etc.



*Note* The 'FONT' mnemonic works with *WINPRT*, but not with any of the text-mode printers.


  Maximum column and line values are zero-based. In the following example, the MXC( ) value returned is 79, for 0-79 = 80 columns:

C=MXC(30)+1 ! For this printer MXC(30) returns 79, C=80 (0-79)
L=MXL(30)+1 ! For this printer MXL(30) returns 55, L=56 (0-55)

Your string variable in reading properties returns a printer-specific list (here, for the ASIS printer):

WINPRT_SETUP READ PROPERTIES WHAT_PROP$
-:?what_prop$ RANGE=ALL;COLLATE=NO;COPIES=1;ORIENTATION=PORTRAIT;PAPERSIZE=1;SOURCE=1;
RESOLUTION=300:300;OFFSET=0:0;TRUETYPE=2;DRIVER=WINSPOOL

-:close (30)

   
Format 3 Open for [WDX]

OPEN [INPUT] (chan[,fileopt])"[WDX]*WINPRT*[;Q_name[Q_options]"

On an NT or PC server, if you include [WDX] in your OPEN [INPUT] directive (e.g., OPEN (30)"[WDX]*WINPRT*"), that signals ProvideX to direct any print jobs and dialogues to the WindX client PC, which will in turn use its Windows print subsystem to send jobs to the given printer.

If you are using *WINPRT* on an NT Server and do not use [WDX] in your OPEN directive, then the printer selection dialogue will appear on the server console, and any print queue you name directly must exist on the NT server in the Control Panel printers folder.

Reminder: You must install and use WindX to use *WINPRT* in a UNIX environment; however, you do not need the [WDX] tag on a UNIX server because ProvideX automatically directs *WINPRT* access to your WindX client PC.
   
See Also WINPRT_SETUP Directive
MXC( ) / MXL( ) Functions
'FONT' Mnemonic
*WINPRT* / *WINDEV* Printing Examples
[WDX] Tag