# \*WINPRT\* Windows Printing

> Source: https://manual.pvxplus.com/file-handling/winprt

## Formats

|  |  |  |
| --- | --- | --- |
| 1\. | [Open Device File](https://manual.pvxplus.com/file-handling/winprt#Mark6)*:* | OPEN (*chan*\[,*fileopt*\])"\*WINPRT\*\[;*Q_name*\[*Q_options*\]" |
| 2\. | [Open for Read-Only](https://manual.pvxplus.com/file-handling/winprt#Mark8)*:* | OPEN INPUT (*chan*\[,*fileopt*\])"\*WINPRT\*\[;*Q_name*\[*Q_options*\]" |
| 3\. | [Open for \[WDX\]](https://manual.pvxplus.com/file-handling/winprt#Mark11)*:* | 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:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| **ERR**=*stmtref* \| Error transfer \|<br>\| **OPT**=*char$* \| File open options \|<br>See **[About File OPEN Options](https://manual.pvxplus.com/directives/open#Mark5)** for the **OPEN** directive.<br>To obtain the current **OPT=** value, use the [OPT( )](https://manual.pvxplus.com/functions/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.)  <br>  <br>Valid *Q_name* options include:<br>\|  \|<br>\| --- \|<br>\| - OS name of an existing physical print queue on the local Windows machine:  <br>    <br>   open (14)"\*WINPRT\*;HP LaserJet" \|<br>\| - 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):  <br>    <br>   open (14)"\*WINPRT\*;HPLaserJet ON \\\\Main_Server\\P Laser"  <br>   open (14)"\*WINPRT\*;LP ON LPT1" \|<br>\| - One of the following queue selection keywords:<br>**ASIS**<br>Most recently selected printer and properties<br>**DEFAULT**<br>Printer currently "Set As Default" in the system (e.g. open (30,err=9900)"\*WINPRT\*;DEFAULT")<br>**NORMAL**<br>Normal dialogue with page range (no paper size, source tray)<br>**SETUP**<br>Setup dialogue with paper size, source tray (no page range) \|<br>While the *Q_name* is optional, it is mandatory in directives if you want to assign or override queue properties (*Q_options* below). See **[\*WINPRT\* / \*WINDEV\* Queues](https://manual.pvxplus.com/file-handling/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).  <br>  <br>Use **;** (*semi-colons*) 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***).  <br>  <br>Specific properties are listed under [WINPRT_SETUP Properties](https://manual.pvxplus.com/directives/winprt-setup#Mark5). See [\*WINPRT\* and \*WINDEV\* Queue Properties.](https://manual.pvxplus.com/file-handling/winprt-windev-queues#Mark8)<br>***Example:***  <br>  <br> open (30)"\*WINPRT\*;HP LaserJet;orientation=landscape;copies=3" |
| **\[WDX\]** | **\*WINPRT\*** is specific to Windows operating systems. Under UNIX, PxPlus automatically directs **\*WINPRT\*** access to the WindX client:  <br>  <br> open (14)"\*winprt\*" ! For the PC client from UNIX host  <br>  <br>In a Windows NT environment, you are opening the **\*WINPRT\*** printer relative to the host unless you prefix the printer name with the **[\[WDX\]](https://manual.pvxplus.com/command-tags/wdx)** tag:<br>```<br>open (14)"*winprt*" ! For the NT host<br>open (14)"[WDX]*winprt*" ! For the NT PC client<br>```<br>The **\*WINPRT\*** Keyword is not case sensitive. Special device filename, enclosed in quotation marks within the **[OPEN](https://manual.pvxplus.com/directives/open)** directive. (Include **\*** *asterisks* in syntax) |

## Description

Note:  
\*WINPRT\* is supported for use in *WindX* or *Windows only*.

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](https://manual.pvxplus.com/file-handling/windev).

The device driver for your given printer interprets the data you send to the \***WINPRT**\* channel and 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.

PxPlus recognizes **\*WINPRT\*** as a special device file in your **OPEN \[INPUT\]** directive and deals with it internally in the language at run time. PxPlus returns an Error #12: File does not exist (or already exists) on the **OPEN** if no printers are installed or if the user selects 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 (e.g. range=1,5 instead of the correct range=1:5). The result can be unpredictable. The driver can even cause your PxPlus 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](https://manual.pvxplus.com/file-handling/windev).

## Format 1

***Open Device File***

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

Use this format to open the **\*WINPRT\*** device file. PxPlus 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.](https://manual.pvxplus.com/file-handling/winprt-windev-printing)

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 is closed. Use the [OPEN INPUT](https://manual.pvxplus.com/directives/open) directive 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](https://manual.pvxplus.com/directives/open)** 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](https://manual.pvxplus.com/directives/winprt-setup#Mark12) directive, a **['FONT'(LIST)](https://manual.pvxplus.com/mnemonics/font)** graphics mnemonic or the **[MXC( ) / MXL( )](https://manual.pvxplus.com/functions/mxc)** functions without generating a Form Feed:

```
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,CourierNew,Times New Roman, ... etc.
```

Note:  
The ['FONT'](https://manual.pvxplus.com/mnemonics/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 (in the following example, it is 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 PxPlus 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.

Note:
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 PxPlus automatically directs \*WINPRT\* access to your WindX client PC.

## See Also

[WINPRT_SETUP Windows Printer Setup](https://manual.pvxplus.com/directives/winprt-setup)  
[MXC( ) / MXL( ) Return Maximum Column/Line](https://manual.pvxplus.com/functions/mxc)  
['FONT' Define/List Fonts](https://manual.pvxplus.com/mnemonics/font)  
**['TEXT' Draw Text](https://manual.pvxplus.com/mnemonics/text)**  
[\*WINPRT\* / \*WINDEV\* Printing Examples](https://manual.pvxplus.com/file-handling/winprt-windev-printing)  
[\[WDX\] Direct Action to Client Machine](https://manual.pvxplus.com/command-tags/wdx)
