XPRINT PRINT statement

Purpose | Output text to be printed on the selected printer.
Syntax | XPRINT PRINT [EXPRLIST] [POS(n)] [SPC(n)] [TAB(n)] [,] [;]... XPRINT [EXPRLIST] [POS(n)] [SPC(n)] [TAB(n)] [,] [;]...

Remarks

Prior to any XPRINT operations, you should be certain that a printer has been selected with XPRINT ATTACH. The text foreground and background color are set with XPRINT COLOR. Text which extends beyond the bounds of the page is clipped. The size of the text to be printed can be determined in advance with XPRINT TEXT SIZE, and formatted to fit a particular field with XPRINT SPLIT. Drawing begins at the last point referenced by another statement, or the point specified by XPRINT SET POS. The upper left corner of the text is positioned at the POS.

XPRINT PRINT has the following parts, which may occur in any order and quantity, within a single statement:

EXPRLIST | String and/or numeric expression(s) which are written to the page. A semicolon can be used as separator between multiple expressions in the same statement. Upon completion, the POS is moved to the left margin of the next line.
POS(n) | An optional function used to set the POS to the horizontal page unit (pixel, scaled unit, etc.) specified by the numeric argument, Multiple uses of the POS function is permitted in a single statement. The vertical position is unchanged.
SPC(n) | An optional function used to insert n spaces into the printed output. Multiple uses of SPC is permitted in a single statement. Values of n less than 1 are ignored.
TAB(n) | An optional function used to tab to the nth column before printing the next expression. Multiple use of TAB is permitted in a single statement. Since TAB references columns, rather than pixels, it can give unpredictable results when used with a variable width font. It is best used with a fixed width font.
[;|,] | Special characters that determine the position of the next text item printed. A semicolon (;) means the next text item is printed immediately; a comma (,) means the next text item is printed at the start of the next print zone. Print zones begin every 14 columns.

If the final argument is a semicolon or comma, the POS is maintained at the current location, rather than the default action of moving to the start of the next line. For example:

XPRINT PRINT "Hello";

XPRINT PRINT " world!";

...produces the contiguous result "Hello world!"

If you omit all arguments, XPRINT PRINT just moves the POS to the left margin of the next line. Any control codes, such as Carriage Return, Line-Feed, and Backspace are not interpreted. They will display as symbols in the current selected font.

USING$ is a separate function, which may be included in the ExprList. See the USING$() function for more information.

It is not possible to print a User-Defined Type (UDT), a Variant, an object variable, or an entire array. Individual member values must be extracted with the appropriate function before they can be displayed.

See also | FONT NEW, LPRINT, XPRINT ATTACH, XPRINT CELL, XPRINT CHR SIZE, XPRINT COLOR, XPRINT CLOSE, XPRINT SET FONT, XPRINT GET POS, XPRINT SET POS, XPRINT SET WORDWRAP, XPRINT SET WRAP, XPRINT SPLIT, 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