LPRINT statement

Purpose | Output (device-dependent) text and data to a printer device.
Syntax | LPRINT [expression] [SPC(n)] [TAB(n)] [,] [;]

Remarks

The LPRINT functionality is identical to the traditional PRINT statement, except that the data is sent directly to a line printer rather than to a display. A line printer is one which will accept standard ASCII text and associated control codes, such as $CR, $LF, and $FF.

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 comma moves the printer position to the next column of 14 positions each. A trailing semi-colon suppresses the final CR/LF. If TAB(n) is less than the current printer position, output is placed at the requested position on the following line.

Before you execute an LPRINT statement, you must explicitly connect to the intended line printer using the LPRINT ATTACH statement. If the connection to the device is unsuccessful, all LPRINT statements are ignored until a valid printer device has been attached. LPRINT communicates directly with the attached device, bypassing the Windows operating system and printer driver. Therefore, any settings such as "work offline" in your printer properties dialog will be ignored.

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

Host-based (Windows-only) printers use proprietary control protocols so, sending print data to them with LPRINT is unlikely to produce any output at all. PowerBASIC supports host-based printers through XPRINT and related statements.

See also | LPRINT ATTACH, LPRINT CLOSE, LPRINT FLUSH, LPRINT FORMFEED, LPRINT$, XPRINT, XPRINT ATTACH

Example

' Typical LPRINT printing strategy

ERRCLEAR

LPRINT ATTACH "LPT2" ' Use LPT2 device

IF ISFALSE ERR AND ISTRUE LEN(LPRINT$) THEN

LPRINT "This is your line-printer talking"

LPRINT FORMFEED ' Issue a formfeed

LPRINT FLUSH ' flush the buffer

LPRINT CLOSE ' detach the printer

END IF