XPRINT statement

Purpose

Output text to a host-printer device.

Syntax

XPRINT [expression] [;]

Remarks

The XPRINT functionality is similar to the PRINT statement, except that the data is sent to a host printer rather than to a display.  A host printer is a Windows-Only printer which uses a device driver to form text and graphics.

PowerBASIC inserts a carriage return and linefeed at the end of each printed line.  A semi-colon between expressions is an optional delimiter which leaves the printer column position unchanged.  A trailing semi-colon suppresses the final CR/LF.

Before you execute an XPRINT statement, you must explicitly connect to the intended host printer using the XPRINT ATTACH statement.  If the connection to the device is unsuccessful, all XPRINT statements are ignored until a valid printer device has been attached.

Once all the data has been sent to the printer, detach the printer so other applications can use it., with the XPRINT CLOSE statement.

Host-based (Windows-only) printers use proprietary control protocols.  Generally speaking, you should avoid the embedding of control codes like $CR, $LF, and $FF in a string expression, as they may not produce the expected results.  Instead, use XPRINT without a parameter to move to the next line, or XPRINT FORMFEED to start a new page.  If the XPRINT operation is not successful, an appropriate error is generated.

See also

LPRINT, XPRINT ATTACH, XPRINT CHR SIZE, XPRINT COLOR, XPRINT CLOSE, XPRINT FONT, XPRINT GET POS, XPRINT SET POS, XPRINT TEXT SIZE

Example

' Typical XPRINT printing strategy

ERRCLEAR

XPRINT ATTACH DEFAULT  ' Use default printer

IF ERR = 0 AND LEN(XPRINT$) > 0 THEN

  XPRINT "This is your printer talking"

  XPRINT FORMFEED      ' Issue a formfeed

  XPRINT CLOSE         ' detach the printer

END IF