XPRINT Code Group

Purpose

The XPRINT Code Group offers statements and functions which draw text and graphics on a Host Printer Page.  In addition, it provides a wide variety of support to manage and interact with these items.

Syntax

XPRINT DirectorWord [params]

XPRINT DirectorWord [params] TO ReturnVariable(s)

Function Form:

ReturnVariable  = XPRINT(DirectorWord [,params] )

ReturnVariable$ = XPRINT$(DirectorWord [,params] )

Remarks

Some of the functionality of the XPRINT group was available in prior versions of PowerBASIC, but it has now been expanded.  Some XPRINT Procedures (namely those which return a single value) may be used in two forms, a statement with a TO clause, or a function which may be used as a term in an expression:

XPRINT GET LINES TO LineCountVar&

LineCountVar& = XPRINT(LINES)

The two examples above are functionally identical.  The choice is simply a matter of your personal preference.  If you use the second form (as a function which returns a value), it can be a term in any expression of any complexity.  When a function form is available, it is labeled with the prefix "Function Form".

Some XPRINT procedures return two or more values.  As it is not possible to simultaneously inject multiple terms into a valid expression, the function option is not available for them.

PIXELS and POINTS

For the purposes of this discussion on XPRINT, the terms PIXELS and POINTS are considered to be synonyms.  They may be used interchangeably.

XPRINT STREAM

The XPRINT Stream is the connection between XPRINT code and a host printer page.  The XPrint Stream is created when you attach a particular printer with XPRINT ATTACH.  From that moment forward, all XPrint code acts on that selected printer.  This continues until such time as you end your print job with XPRINT CLOSE.

PAGE UNITS

PAGE UNITS are used to measure the size of a graphical item, or to define a particular position on an XPrint page.  You can define page units to be points or scaled units of your choice.

Initially, each XPrint session begins with Page Units set to points. You can change this to scaled world coordinates of your choice with XPRINT SCALE.

By default, the upper left corner of a printer page is considered to be the X,Y position 0,0 and grows larger to the right or downward. The X axis is horizontal, while the Y axis is vertical.  Whenever an X,Y position is given, the X value is stated first.

XPRINT POSITION (POS)

Each time you draw text or graphics, it is displayed at the current XPrint position (POS).  Upon completion, the POS is updated to the last point referenced.  You can draw a relative distance from the POS (using a STEP option), or set an entirely new position with XPRINT SET POS.

TEXT CELL (ROW/COLUMN POSITION)

For ease of programming, a few procedures specify text position by row and column.  In this case, the position is measured in text cells, which is the space occupied by one character.  This works well with fixed width fonts, which is recommended.  If a variable width font is chosen, PowerBASIC must use the average character size for these calculations, which can give imprecise results.

For compatibility with most current and prior versions of BASIC (PowerBASIC included), code which references text rows and columns names the vertical term first (ROWS, COLUMNS).  Rows and columns are always numbered from one upward.

See also

Printing, Printing Commands