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 for the OPEN directive.

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 *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 ; (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).

Specific properties are listed under WINPRT_SETUP Properties. See *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, PxPlus automatically directs *WINPRT* access to the WindX client:

     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:

     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 the 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.

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.

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.

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 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 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( ) / MXL( ) 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' 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
MXC( ) / MXL( ) Return Maximum Column/Line
'FONT' Define/List Fonts
'TEXT' Draw Text
*WINPRT* / *WINDEV* Printing Examples
[WDX] Direct Action to Client Machine